@@ -13,27 +13,61 @@ defaults:
13
13
shell : bash -l {0}
14
14
15
15
jobs :
16
- update-reference-screenshots :
17
- name : Update Galata References
18
- if : ${{ github.event.issue.pull_request && contains(github.event.comment.body, 'update galata references') }}
16
+ update-snapshots :
17
+ if : >
18
+ (
19
+ github.event.issue.author_association == 'OWNER' ||
20
+ github.event.issue.author_association == 'COLLABORATOR' ||
21
+ github.event.issue.author_association == 'MEMBER'
22
+ ) && github.event.issue.pull_request && contains(github.event.comment.body, 'please update snapshots')
19
23
runs-on : ubuntu-latest
20
24
21
25
steps :
26
+ - name : React to the triggering comment
27
+ run : |
28
+ gh api repos/${{ github.repository }}/issues/comments/${{ github.event.comment.id }}/reactions --raw-field 'content=+1'
29
+ env :
30
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
31
+
22
32
- name : Checkout
23
- uses : actions/checkout@v3
33
+ uses : actions/checkout@v4
24
34
with :
25
35
token : ${{ secrets.GITHUB_TOKEN }}
26
36
27
- - name : Configure git to use https
28
- run : git config --global hub.protocol https
37
+ - name : Get PR Info
38
+ id : pr
39
+ env :
40
+ PR_NUMBER : ${{ github.event.issue.number }}
41
+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
42
+ GH_REPO : ${{ github.repository }}
43
+ COMMENT_AT : ${{ github.event.comment.created_at }}
44
+ run : |
45
+ pr="$(gh api /repos/${GH_REPO}/pulls/${PR_NUMBER})"
46
+ head_sha="$(echo "$pr" | jq -r .head.sha)"
47
+ pushed_at="$(echo "$pr" | jq -r .pushed_at)"
48
+
49
+ if [[ $(date -d "$pushed_at" +%s) -gt $(date -d "$COMMENT_AT" +%s) ]]; then
50
+ echo "Updating is not allowed because the PR was pushed to (at $pushed_at) after the triggering comment was issued (at $COMMENT_AT)"
51
+ exit 1
52
+ fi
29
53
30
- - name : Install hub
31
- run : sudo apt-get update && sudo apt-get install -y hub
54
+ echo "head_sha=$head_sha" >> $GITHUB_OUTPUT
32
55
33
56
- name : Checkout the branch from the PR that triggered the job
34
- run : hub pr checkout ${{ github.event.issue.number }}
35
57
env :
36
58
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
59
+ run : gh pr checkout ${{ github.event.issue.number }}
60
+
61
+ - name : Validate the fetched branch HEAD revision
62
+ env :
63
+ EXPECTED_SHA : ${{ steps.pr.outputs.head_sha }}
64
+ run : |
65
+ actual_sha="$(git rev-parse HEAD)"
66
+
67
+ if [[ "$actual_sha" != "$EXPECTED_SHA" ]]; then
68
+ echo "The HEAD of the checked out branch ($actual_sha) differs from the HEAD commit available at the time when trigger comment was submitted ($EXPECTED_SHA)"
69
+ exit 1
70
+ fi
37
71
38
72
- name : Install Conda environment with Micromamba
39
73
uses : mamba-org/setup-micromamba@main
51
85
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD : 1
52
86
run : jlpm install
53
87
54
- - uses : jupyterlab/maintainer-tools/.github/actions/update-snapshots@main
88
+ - uses : jupyterlab/maintainer-tools/.github/actions/update-snapshots@v1
55
89
with :
56
90
npm_client : jlpm
57
91
github_token : ${{ secrets.GITHUB_TOKEN }}
0 commit comments