forked from hasadna/open-bus-map-search
-
Notifications
You must be signed in to change notification settings - Fork 0
103 lines (93 loc) · 3.98 KB
/
Copy pathdeploy-preview.yml
File metadata and controls
103 lines (93 loc) · 3.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
name: Deploy Preview
on:
workflow_run:
workflows: ['Build']
types:
- completed
permissions:
contents: read
pull-requests: write
issues: write
jobs:
deploy-to-s3:
name: Deploy to S3
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download dist-build artifact
uses: dawidd6/action-download-artifact@v11
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@v11
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@v11
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 | tr -d '\n' | grep -E '^[0-9]+$' || echo "")
if [ -z "$pr_number" ]; then
echo "Error: Invalid PR number" >&2
exit 1
fi
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@v3
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@v4
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@v4
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'