Skip to content

Commit

Permalink
update artifact url in readme when merge.yml is run
Browse files Browse the repository at this point in the history
  • Loading branch information
jasminabrar authored Dec 19, 2023
1 parent 4a0aa70 commit 6e102a2
Showing 1 changed file with 41 additions and 2 deletions.
43 changes: 41 additions & 2 deletions .github/workflows/merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/
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="<!-- start-link -->"
end_delim="<!-- end-link -->"
# 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'}}

0 comments on commit 6e102a2

Please sign in to comment.