diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index 8dde7e7d..8bc44af3 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -3,6 +3,10 @@ name: "update_dockerfiles" on: schedule: - cron: '57 19 * * *' + workflow_dispatch: # Allow manual triggering + +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} jobs: update_dockerfiles: @@ -10,6 +14,9 @@ jobs: 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 @@ -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 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." + \ No newline at end of file