diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml index 035336ef..27fd37b5 100644 --- a/.github/workflows/merge.yml +++ b/.github/workflows/merge.yml @@ -45,7 +45,46 @@ jobs: done - name: upload artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 + id: artifact-upload with: name: merge-files - path: merge_output/ \ No newline at end of file + path: merge_output/ + + - name: get artifact url + run: | + IFS='/' read -ra REPO <<< "$GITHUB_REPOSITORY" + OWNER="${REPO[0]}" + REPO_NAME="${REPO[1]}" + echo "Owner: $OWNER" + echo "Repository: $REPO_NAME" + + RUN_ID=${{ github.run_id }} + ARTIFACT_ID=${{ steps.artifact-upload.outputs.artifact-id }} + ARTIFACT_URL="https://github.com/$OWNER/$REPO_NAME/actions/runs/$RUN_ID/artifacts/$ARTIFACT_ID" + echo "Artifact URL: $ARTIFACT_URL" + + echo "ARTIFACT_URL=$ARTIFACT_URL" >> $GITHUB_ENV + echo "OWNER=$OWNER" >> $GITHUB_ENV + + - name: update url in runner README + run: | + start_delim="" + end_delim="" + + # remove current URL + sed -i "/$start_delim/,/$end_delim/d" README.md + + # add new URL + printf "$start_delim\n$ARTIFACT_URL\n$end_delim\n" >> README.md + + # merge script always runs on any PR, this ensures link is only updated after a PR is merged into SiEPIC + - name: commit and push changes to README if we are in SiEPIC repo + run: | + git diff + git config --local user.email "${{ github.actor }}@users.noreply.github.com" + git config --local user.name "${{ github.actor }}" + git add README.md + git commit -m "update README with new artifact url" + git push + if: ${{ env.OWNER == 'SiEPIC'}}