Skip to content

Commit

Permalink
improve update workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
ImreSamu committed Jul 3, 2024
1 parent 8de5930 commit 009635e
Showing 1 changed file with 53 additions and 8 deletions.
61 changes: 53 additions & 8 deletions .github/workflows/update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,20 @@ name: "update_dockerfiles"
on:
schedule:
- cron: '57 19 * * *'
workflow_dispatch: # Allow manual triggering

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
update_dockerfiles:
name: "update_dockerfiles"
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for all branches and tags

- run: docker ps -a
- name: Login to dockerhub
uses: docker/login-action@v3
Expand Down Expand Up @@ -40,22 +47,60 @@ jobs:
echo "versions.json not changed"
fi
- name: Check for existing open PRs with label 'automated_pr'
if: env.versions_changed == 'true'
id: check_prs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
existing_prs=$(gh pr list --label automated_pr --json number --jq length)
if [ "$existing_prs" -eq "0" ]; then
echo "create_pr=true" >> $GITHUB_OUTPUT
else
echo "create_pr=false" >> $GITHUB_OUTPUT
echo "An automated PR already exists. Skipping PR creation."
fi
# https://github.com/peter-evans/create-pull-request
- name: Create Pull Request
if: env.versions_changed == 'true'
if: env.versions_changed == 'true' && steps.check_prs.outputs.create_pr == 'true'
id: create-pr
uses: peter-evans/create-pull-request@v6
with:
# token: ${{ secrets.POSTGIS_PR_REPO_TOKEN }}
committer: GitHub <noreply@github.com>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
commit-message: Update versions.json and related Dockerfiles
title: '🤖 Bump the: ${{ env.versions_changed_list }}'
commit-message: '🤖 Bump versions: ${{ env.versions_changed_list }}'
title: '🤖 Bump versions: ${{ env.versions_changed_list }}'
body: |
Update docker-postgis versions.json and related Dockerfiles.
Changes: ${{ env.versions_changed_list }}
## Automated Version Update
This pull request was automatically generated by the `update_dockerfiles` workflow ( `.github/workflows/update.yml`)
to update docker-postgis versions.json and related Dockerfiles.
### Changes
${{ env.versions_changed_list }}
### Important Notes
1. **Verification Required**: Please carefully review the changes to ensure they are correct and appropriate.
2. **PR Limit**: While this PR remains open, no new automated PRs will be created by this workflow. This ensures only one automated update is processed at a time.
If you have any questions or concerns, please comment on this PR or contact the maintainers.
Auto-generated by .github/workflows/update.yml
Please verify if the changes are correct!
labels: automated_pr
branch: ${{ env.BRANCH_NAME }}
delete-branch: true

- name: Close and Reopen PR
if: steps.create-pr.outputs.pull-request-number
run: |
PR_NUMBER=${{ steps.create-pr.outputs.pull-request-number }}
gh pr close $PR_NUMBER --comment "Closing to trigger full CI/CD pipeline"
sleep 5 # Wait for 5 seconds to ensure the PR is fully closed
gh pr reopen $PR_NUMBER --comment "Reopening to trigger full CI/CD pipeline"
- name: Comment PR
if: steps.create-pr.outputs.pull-request-number
run: |
PR_NUMBER=${{ steps.create-pr.outputs.pull-request-number }}
gh pr comment $PR_NUMBER --body "This PR was automatically created and reopened by the update_dockerfiles workflow to trigger the full CI/CD pipeline. Please review the changes carefully."

0 comments on commit 009635e

Please sign in to comment.