|
| 1 | +on: |
| 2 | + workflow_run: |
| 3 | + workflows: ["Build"] |
| 4 | + types: |
| 5 | + - completed |
| 6 | + |
| 7 | +jobs: |
| 8 | + deploy-to-s3: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + steps: |
| 11 | + - uses: actions/checkout@v2 |
| 12 | + - name: Download artifact |
| 13 | + uses: dawidd6/action-download-artifact@v2 |
| 14 | + with: |
| 15 | + workflow: 'Build' |
| 16 | + workflow_conclusion: success |
| 17 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 18 | + run_id: ${{ github.event.workflow_run.id }} |
| 19 | + run_number: ${{ github.event.workflow_run.run_number }} |
| 20 | + name: dist |
| 21 | + path: dist |
| 22 | + - name: Download pr number |
| 23 | + uses: dawidd6/action-download-artifact@v2 |
| 24 | + with: |
| 25 | + workflow: 'Build' |
| 26 | + workflow_conclusion: success |
| 27 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 28 | + run_id: ${{ github.event.workflow_run.id }} |
| 29 | + run_number: ${{ github.event.workflow_run.run_number }} |
| 30 | + name: pr_number |
| 31 | + path: . |
| 32 | + - name: Read PR number |
| 33 | + id: read-pr |
| 34 | + run: | |
| 35 | + pr_number=$(cat pr_number) |
| 36 | + echo "PR_NUMBER=${pr_number}" >> $GITHUB_ENV |
| 37 | + - uses: shallwefootball/s3-upload-action@master |
| 38 | + name: Upload preview to S3 |
| 39 | + if: always() |
| 40 | + id: s3-trace |
| 41 | + continue-on-error: true |
| 42 | + with: |
| 43 | + aws_key_id: ${{ secrets.AWS_KEY_ID }} |
| 44 | + aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY}} |
| 45 | + aws_bucket: noam-gaash.co.il |
| 46 | + source_dir: dist |
| 47 | + destination_dir: ${{ github.event.workflow_run.id }}/open-bus/${{ github.event.workflow_run.run_number }} |
| 48 | + - name: find comment |
| 49 | + uses: peter-evans/find-comment@v1 |
| 50 | + if: env.PR_NUMBER |
| 51 | + id: fc |
| 52 | + with: |
| 53 | + issue-number: ${{ env.PR_NUMBER }} |
| 54 | + comment-author: 'github-actions[bot]' |
| 55 | + body-includes: 'Preview' |
| 56 | + - name: update comment |
| 57 | + uses: peter-evans/create-or-update-comment@v1 |
| 58 | + if: steps.fc.outputs.comment-id |
| 59 | + with: |
| 60 | + comment-id: ${{ steps.fc.outputs.comment-id }} |
| 61 | + edit-mode: replace |
| 62 | + body: | |
| 63 | + Preview: https://s3.amazonaws.com/noam-gaash.co.il/${{ github.event.workflow_run.id }}/open-bus/${{ github.event.workflow_run.run_number }}/index.html |
| 64 | + Preview Storybook: https://s3.amazonaws.com/noam-gaash.co.il/${{ github.event.workflow_run.id }}/open-bus/${{ github.event.workflow_run.run_number }}/storybook/index.html |
| 65 | + - name: create comment |
| 66 | + uses: peter-evans/create-or-update-comment@v1 |
| 67 | + if: steps.fc.outputs.comment-id == '' |
| 68 | + with: |
| 69 | + issue-number: ${{ env.PR_NUMBER }} |
| 70 | + body: | |
| 71 | + Preview: https://s3.amazonaws.com/noam-gaash.co.il/${{ github.event.workflow_run.id }}/open-bus/${{ github.event.workflow_run.run_number }}/index.html |
| 72 | + Preview Storybook: https://s3.amazonaws.com/noam-gaash.co.il/${{ github.event.workflow_run.id }}/open-bus/${{ github.event.workflow_run.run_number }}/storybook/index.html |
0 commit comments