.github/workflows/deploy-preview.yml #124
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | |
workflow_run: | |
workflows: ["Build"] | |
types: | |
- completed | |
jobs: | |
deploy-to-s3: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Download dist-build artifact | |
uses: dawidd6/action-download-artifact@v4 | |
with: | |
workflow: 'Build' | |
workflow_conclusion: success | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
run_id: ${{ github.event.workflow_run.id }} | |
run_number: ${{ github.event.workflow_run.run_number }} | |
name: dist-build | |
path: . | |
- name: Download dist-storybook artifact | |
uses: dawidd6/action-download-artifact@v4 | |
with: | |
workflow: 'Build' | |
workflow_conclusion: success | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
run_id: ${{ github.event.workflow_run.id }} | |
run_number: ${{ github.event.workflow_run.run_number }} | |
name: dist-storybook | |
path: storybook | |
- name: Download pr number | |
uses: dawidd6/action-download-artifact@v6 | |
with: | |
workflow: 'Build' | |
workflow_conclusion: success | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
run_id: ${{ github.event.workflow_run.id }} | |
run_number: ${{ github.event.workflow_run.run_number }} | |
name: pr_number | |
path: . | |
- name: Read PR number | |
id: read-pr | |
run: | | |
pr_number=$(cat pr_number) | |
echo "PR_NUMBER=${pr_number}" >> $GITHUB_ENV | |
- uses: shallwefootball/s3-upload-action@master | |
name: Upload preview to S3 | |
if: always() | |
id: s3-trace | |
continue-on-error: true | |
with: | |
aws_key_id: ${{ secrets.AWS_KEY_ID }} | |
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws_bucket: noam-gaash.co.il | |
source_dir: . # Upload the root directory | |
destination_dir: ${{ github.event.workflow_run.id }}/open-bus/${{ github.event.workflow_run.run_number }} | |
- name: find comment | |
uses: peter-evans/find-comment@v1 | |
if: env.PR_NUMBER | |
id: fc | |
with: | |
issue-number: ${{ env.PR_NUMBER }} | |
comment-author: 'github-actions[bot]' | |
body-includes: 'Preview' | |
- name: update comment | |
uses: peter-evans/create-or-update-comment@v1 | |
if: steps.fc.outputs.comment-id | |
with: | |
comment-id: ${{ steps.fc.outputs.comment-id }} | |
edit-mode: replace | |
body: | | |
Preview: https://s3.amazonaws.com/noam-gaash.co.il/${{ github.event.workflow_run.id }}/open-bus/${{ github.event.workflow_run.run_number }}/index.html | |
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 | |
Test Report (if available): 'https://s3.amazonaws.com/noam-gaash.co.il/${{ github.event.workflow_run.id }}/open-bus/${{ github.event.workflow_run.head_sha }}/test-results/index.html' | |
- name: create comment | |
uses: peter-evans/create-or-update-comment@v1 | |
if: steps.fc.outputs.comment-id == '' | |
with: | |
issue-number: ${{ env.PR_NUMBER }} | |
body: | | |
Preview: https://s3.amazonaws.com/noam-gaash.co.il/${{ github.event.workflow_run.id }}/open-bus/${{ github.event.workflow_run.run_number }}/index.html | |
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 | |
Test Report (if available): 'https://s3.amazonaws.com/noam-gaash.co.il/${{ github.event.workflow_run.id }}/open-bus/${{ github.event.workflow_run.head_sha }}/test-results/index.html' |