-
Notifications
You must be signed in to change notification settings - Fork 14
83 lines (70 loc) · 3.05 KB
/
update-e2e-snapshot.yml
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
name: Update E2E Snapshot when comment on pr
on:
issue_comment:
types: [created]
jobs:
update-snapshot:
# The type of runner that the job will run on
runs-on: ubuntu-latest
if: contains(github.event.comment.html_url, '/pull/') && contains(github.event.comment.body, '/update-e2e-snapshot')
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: listen for PR Comments
uses: machine-learning-apps/actions-chatops@master
with:
TRIGGER_PHRASE: "/update-e2e-snapshot"
env: # you must supply GITHUB_TOKEN
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
id: prcomm
# This step clones the branch of the PR associated with the triggering phrase, but only if it is triggered.
- name: clone branch of PR
if: steps.prcomm.outputs.BOOL_TRIGGERED == 'true'
uses: actions/checkout@master
with:
ref: ${{ steps.prcomm.outputs.BRANCH_NAME }}
- name: Show current running workflows' id
if: steps.prcomm.outputs.BOOL_TRIGGERED == 'true'
uses: peter-evans/create-or-update-comment@23ff15729ef2fc348714a3bb66d2f655ca9066f2 # v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.issue.number }}
body: |
Update E2E Snapshot Triggered!
Address: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
- name: Try update snapshot
if: steps.prcomm.outputs.BOOL_TRIGGERED == 'true'
run: |
cd e2e
echo ::group::build
make server compose-args="--detach"
make wait-server
echo ::endgroup::build
make update-snapshot
make test # ensure test pass after update
- name: Commit result
if: steps.prcomm.outputs.BOOL_TRIGGERED == 'true'
run: |
git pull
git config --global user.name ${{ github.event.comment.user.login }}
git config --global user.email ${{ github.event.comment.user.login }}@github.fake
git add .
git commit -am 'test(e2e): update snapshot'
- name: Push changes
if: steps.prcomm.outputs.BOOL_TRIGGERED == 'true'
uses: ad-m/github-push-action@master
with:
# use my own token instead of GITHUB_TOKEN to trigger future workflows
github_token: ${{ secrets.WORKFLOW_TOKEN }}
branch: ${{ steps.prcomm.outputs.BRANCH_NAME }}
- name: Upload artifact if failed
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3
if: failure() && steps.prcomm.outputs.BOOL_TRIGGERED == 'true'
with:
name: e2e-snapshots
path: e2e/cypress/snapshots
- name: Upload artifact if failed
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3
if: failure() && steps.prcomm.outputs.BOOL_TRIGGERED == 'true'
with:
name: e2e-videos
path: e2e/cypress/videos