|
| 1 | +name: Publish website |
| 2 | +on: |
| 3 | + workflow_run: |
| 4 | + workflows: ["Build website"] |
| 5 | + types: |
| 6 | + - completed |
| 7 | + |
| 8 | +jobs: |
| 9 | + publish: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + env: |
| 12 | + PR_INFO_FILE: ".PR_INFO" |
| 13 | + steps: |
| 14 | + - if: github.event.workflow_run.conclusion != 'success' |
| 15 | + name: Abort if build failed |
| 16 | + run: | |
| 17 | + echo "build failed" |
| 18 | + exit 1 |
| 19 | +
|
| 20 | + # need to checkout to get "firebase.json", ".firebaserc" |
| 21 | + - uses: actions/checkout@v2 |
| 22 | + |
| 23 | + - name: Download build artifact |
| 24 | + uses: dawidd6/action-download-artifact@v2 |
| 25 | + with: |
| 26 | + github_token: "${{ secrets.GITHUB_TOKEN }}" |
| 27 | + workflow: build-website.yml |
| 28 | + run_id: ${{ github.event.workflow_run.id }} |
| 29 | + name: website |
| 30 | + path: website/build/yew |
| 31 | + |
| 32 | + - if: github.event.workflow_run.event == 'pull_request' |
| 33 | + name: Download pr info |
| 34 | + uses: dawidd6/action-download-artifact@v2 |
| 35 | + with: |
| 36 | + github_token: "${{ secrets.GITHUB_TOKEN }}" |
| 37 | + workflow: build-website.yml |
| 38 | + run_id: ${{ github.event.workflow_run.id }} |
| 39 | + name: pr-info |
| 40 | + |
| 41 | + - if: github.event.workflow_run.event == 'pull_request' |
| 42 | + name: Apply pull request environment |
| 43 | + run: | |
| 44 | + pr_number=$(cat "$PR_INFO_FILE") |
| 45 | + if ! [[ "$pr_number" =~ ^[0-9]+$ ]]; then |
| 46 | + echo "pr number invalid" |
| 47 | + exit 1 |
| 48 | + fi |
| 49 | + echo "PR_NUMBER=$pr_number" >> $GITHUB_ENV |
| 50 | + echo "PR_BRANCH=${{ github.event.workflow_run.head_branch }}" >> $GITHUB_ENV |
| 51 | + echo "COMMIT_SHA=${{ github.event.workflow_run.head_sha }}" >> $GITHUB_ENV |
| 52 | +
|
| 53 | + - if: github.event.workflow_run.event == 'push' |
| 54 | + name: Apply push environment |
| 55 | + run: | |
| 56 | + echo "CHANNEL_ID=live" >> $GITHUB_ENV |
| 57 | +
|
| 58 | + - name: Deploy to Firebase |
| 59 | + uses: siku2/action-hosting-deploy@v1 |
| 60 | + with: |
| 61 | + repoToken: "${{ secrets.GITHUB_TOKEN }}" |
| 62 | + firebaseToken: "${{ secrets.FIREBASE_TOKEN }}" |
| 63 | + targets: website |
| 64 | + channelId: "${{ env.CHANNEL_ID }}" |
| 65 | + # link to the next version because that's what we care about |
| 66 | + commentURLPath: "/docs/next/" |
| 67 | + # PR information |
| 68 | + prNumber: "${{ env.PR_NUMBER }}" |
| 69 | + prBranchName: "${{ env.PR_BRANCH }}" |
| 70 | + commitSHA: "${{ env.COMMIT_SHA }}" |
0 commit comments