Remove github.ref from matrix since it's never valid #20
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
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 }} | |
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: Show link to access caller workflow runs | |
if: strategy.job-index == '0' | |
run: | | |
echo "URL for caller workflow run(s): <${{ github.server_url }}/${{ matrix.caller-repository }}/actions>" >> $GITHUB_STEP_SUMMARY |