|
| 1 | +--- |
| 2 | +name: Staging Deploy |
| 3 | +run-name: Publish workshop to staging website (for PR) |
| 4 | + |
| 5 | +on: |
| 6 | + pull_request: |
| 7 | + branches: [main] |
| 8 | + |
| 9 | +permissions: |
| 10 | + id-token: write |
| 11 | + contents: read |
| 12 | + pull-requests: write |
| 13 | + |
| 14 | +jobs: |
| 15 | + build: |
| 16 | + name: Build |
| 17 | + runs-on: ubuntu-latest |
| 18 | + steps: |
| 19 | + - name: Checkout repository |
| 20 | + uses: actions/checkout@v4 |
| 21 | + |
| 22 | + - name: Setup Ruby |
| 23 | + uses: ruby/setup-ruby@v1 |
| 24 | + with: |
| 25 | + ruby-version: '3.3' |
| 26 | + bundler-cache: true |
| 27 | + |
| 28 | + - name: Install Jekyll |
| 29 | + run: | |
| 30 | + gem install jekyll bundler |
| 31 | + if [ -f Gemfile ]; then |
| 32 | + bundle install |
| 33 | + fi |
| 34 | +
|
| 35 | + - name: Build Jekyll site |
| 36 | + run: | |
| 37 | + if [ -f Gemfile ]; then |
| 38 | + bundle exec jekyll build --baseurl "/${{ github.event.repository.name }}/pr/${{ github.event.number }}" |
| 39 | + else |
| 40 | + jekyll build --baseurl "/${{ github.event.repository.name }}/pr/${{ github.event.number }}" |
| 41 | + fi |
| 42 | + env: |
| 43 | + JEKYLL_ENV: production |
| 44 | + |
| 45 | + - name: Upload build artifact |
| 46 | + uses: actions/upload-artifact@v4 |
| 47 | + with: |
| 48 | + name: build-artifact |
| 49 | + path: _site |
| 50 | + if-no-files-found: error |
| 51 | + |
| 52 | + deploy: |
| 53 | + name: Deploy |
| 54 | + runs-on: ubuntu-latest |
| 55 | + needs: build |
| 56 | + environment: |
| 57 | + name: staging |
| 58 | + url: https://staging.overturemaps.org/${{ github.event.repository.name }}/pr/${{ github.event.number }}/index.html |
| 59 | + |
| 60 | + steps: |
| 61 | + - name: Configure AWS credentials 🔐 |
| 62 | + uses: aws-actions/configure-aws-credentials@v4 |
| 63 | + with: |
| 64 | + role-to-assume: arn:aws:iam::763944545891:role/pages-staging-oidc-overturemaps |
| 65 | + aws-region: us-west-2 |
| 66 | + |
| 67 | + - name: Download artifacts 📥 |
| 68 | + uses: actions/download-artifact@v4 |
| 69 | + with: |
| 70 | + name: build-artifact |
| 71 | + path: build |
| 72 | + |
| 73 | + - name: Copy to S3 |
| 74 | + run: | |
| 75 | + aws s3 sync --delete build s3://overture-managed-staging-usw2/gh-pages/${{ github.event.repository.name }}/pr/${{ github.event.number }}/ |
| 76 | +
|
| 77 | + - name: Bust the Cache |
| 78 | + run: aws cloudfront create-invalidation --distribution-id E1KP2IN0H2RGGT --paths "/${{ github.event.repository.name }}/pr/${{ github.event.number }}/*" |
| 79 | + |
| 80 | + - name: Get deploy timestamp |
| 81 | + id: timestamp |
| 82 | + run: echo "time=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT |
| 83 | + |
| 84 | + - name: Comment on PR |
| 85 | + uses: marocchino/sticky-pull-request-comment@v2 |
| 86 | + with: |
| 87 | + message: | |
| 88 | + ## 🚀 Workshop branch preview deployed! |
| 89 | +
|
| 90 | + You can review your changes at https://staging.overturemaps.org/${{ github.event.repository.name }}/pr/${{ github.event.number }}/index.html |
| 91 | +
|
| 92 | + --- |
| 93 | + <sub>♻️ Last refreshed: ${{ steps.timestamp.outputs.time }}</sub> |
0 commit comments