October 2024 dependency updates. #15
Workflow file for this run
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: Update dependabot pull request | |
on: | |
pull_request: | |
types: [opened, labeled, unlabeled, synchronize] | |
jobs: | |
update-title: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Check conditions | |
id: check_conditions | |
run: | | |
if [[ "${{ github.event.pull_request.user.login }}" != "erinesullivan" ]]; then | |
echo "Author does not match." | |
echo "conditions_met=false" >> $GITHUB_ENV | |
exit 0 | |
fi | |
labels=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels | jq -r '.[].name') | |
if [[ $labels != *"dependencies"* ]]; then | |
echo "Label does not match." | |
echo "conditions_met=false" >> $GITHUB_ENV | |
exit 0 | |
fi | |
echo "conditions_met=true" >> $GITHUB_ENV | |
- name: Update PR title | |
if: env.conditions_met == 'true' | |
run: | | |
NEW_TITLE="$(date +'%B %Y') dependency updates." | |
curl -X PATCH \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }} \ | |
-d "{\"title\":\"${NEW_TITLE}\"}" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Generate comment on how to test | |
if: env.conditions_met == 'true' | |
run: | | |
COMMENT="To test on [\`search\`](https:/mlibrary/search), update the \`pride\` dependency in the \`package.json\` file:\n | |
\`\`\`json\n | |
\"pride\": \"git+https:/${REPO}.git#${BRANCH}\"\n | |
\`\`\`\n | |
After updating the dependency, do a clear install before starting:\n | |
\`\`\`bash\n | |
rm -rf node_modules && rm package-lock.json && npm install && npm start\n | |
\`\`\`\n | |
" | |
curl -s \ | |
-H "Authorization: token ${GITHUB_TOKEN}" \ | |
-H "Content-Type: application/json" \ | |
-X POST -d "{\"body\": \"${COMMENT}\"}" \ | |
"https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |