GitHub Actions Version Update #56
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: GitHub Actions Version Update | |
on: | |
schedule: | |
- cron: "0 8 * * *" | |
workflow_dispatch: | |
permissions: | |
contents: write | |
jobs: | |
update-actions: | |
runs-on: ubuntu-latest | |
env: | |
GH_TOKEN: ${{ secrets.DELTA_BOT_GH_TOKEN }} | |
steps: | |
- name: Checkout Repository | |
uses: actions/[email protected] | |
with: | |
token: ${{ secrets.DELTA_BOT_GH_TOKEN }} | |
- name: Update GitHub Actions | |
id: updater | |
uses: saadmk11/[email protected] | |
with: | |
token: ${{ secrets.DELTA_BOT_GH_TOKEN }} | |
skip_pull_request: "true" | |
committer_username: "singulon" | |
committer_email: "[email protected]" | |
continue-on-error: true | |
- name: Check for Changes | |
id: check_changes | |
run: | | |
if [ -n "$(git status --porcelain)" ]; then | |
echo "changes_detected=true" >> "$GITHUB_OUTPUT" | |
else | |
echo "changes_detected=false" >> "$GITHUB_OUTPUT" | |
fi | |
- name: Create Branch, Commit and Push | |
if: ${{ steps.check_changes.outputs.changes_detected == 'true' }} | |
id: commit_push | |
run: | | |
BRANCH_NAME="update-github-actions-$(date +%Y%m%d%H%M%S)" | |
git config --global user.name "singulon" | |
git config --global user.email "[email protected]" | |
git checkout -b "$BRANCH_NAME" | |
git add . | |
git commit -m "Apply changes from Update GitHub Actions" | |
git push "https://x-access-token:${{ secrets.DELTA_BOT_GH_TOKEN }}@github.com/${{ github.repository }}" "$BRANCH_NAME" | |
echo "branch_name=$BRANCH_NAME" >> "$GITHUB_OUTPUT" | |
- name: Create and Merge Pull Request | |
if: ${{ steps.check_changes.outputs.changes_detected == 'true' }} | |
run: | | |
DIFF=$(git diff HEAD~1 HEAD || true) | |
PR_BODY="Bump GitHub Actions versions | |
\`\`\`diff | |
$DIFF | |
\`\`\`" | |
PR_URL=$(gh pr create --base master --head "${{ steps.commit_push.outputs.branch_name }}" --title "Update GitHub Actions" --body "$PR_BODY" --draft=false --label "dependencies") | |
gh pr merge "$PR_URL" --squash --delete-branch --auto |