-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (71 loc) · 2.85 KB
/
test-self.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
name: Test this repository
on:
push:
env:
FORCE_COLOR: "yes"
jobs:
test-with-sample-repo:
name: Test ref=${{ matrix.called-ref }} using sample repo ${{ matrix.caller-repository }}@${{ matrix.caller-ref }}
strategy:
fail-fast: false
matrix:
caller-repository:
- lbianchi-lbl/sample-submission-1
caller-ref:
- main
called-workflow:
- ${{ github.repository }}/.github/workflows/check-submission.yml
called-ref:
- ${{ github.sha }}
- ${{ github.ref_name }}
- ${{ github.ref }}
runs-on: ubuntu-latest
steps:
- name: Wait a bit to avoid race conditions
env:
wait_time_s: ${{ strategy.job-index }}
run: |
sleep $(( 5 * $wait_time_s ))
- name: Define extra metadata
run: |
WORKFLOW_SHORT_SHA="$(echo ${{ github.sha }} | cut -c 1-7)"
WORKFLOW_SHORT_LINK="${{ github.repository }}@${WORKFLOW_SHORT_SHA}"
WORKFLOW_FULL_LINK="${{ matrix.called-workflow }}@${{ github.sha }}"
echo "WORKFLOW_SHORT_SHA=$WORKFLOW_SHORT_SHA" >> $GITHUB_ENV
echo "WORKFLOW_SHORT_LINK=$WORKFLOW_SHORT_LINK" >> $GITHUB_ENV
echo "WORKFLOW_FULL_LINK=$WORKFLOW_FULL_LINK" >> $GITHUB_ENV
- name: Define extra metadata (non-SHA ref)
if: matrix.called-ref != github.sha
run: |
WORKFLOW_SHORT_LINK="${{ github.repository }}@${{ matrix.called-ref }}"
echo "WORKFLOW_SHORT_LINK=$WORKFLOW_SHORT_LINK" >> $GITHUB_ENV
- uses: actions/checkout@v4
with:
repository: ${{ matrix.caller-repository }}
ref: ${{ matrix.caller-ref }}
token: ${{ secrets.CLIENT_REPO_TOKEN }}
- name: Update references to workflow under test with current commit
run: |
git log -n 1
sed -i 's#^\( uses: ${{ matrix.called-workflow }}\)\(@[^[:space:]]*\)#\1@${{ matrix.called-ref }}#' .github/workflows/*.yml
git status -vv
- name: Commit and push changes
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git config --global push.autoSetupRemote true
git add .github/workflows/*.yml
git status -vv
git commit -m "Test $WORKFLOW_SHORT_LINK" -m "Test $WORKFLOW_FULL_LINK"
git push -f
echo "CALLER_SHA=$(git log -n 1 --format='%H')" >> $GITHUB_ENV
- name: Display caller workflow runs for this commit
env:
GH_TOKEN: ${{ secrets.CLIENT_REPO_TOKEN }}
run: |
gh run list \
--repo ${{ matrix.caller-repository }} \
--commit ${{ env.CALLER_SHA }} \
--json url,displayTitle,status \
--template '{{ range .}}{{ .url }}{{ end }}' \
>> $GITHUB_STEP_SUMMARY