Skip to content

update_dockerfiles #303

update_dockerfiles

update_dockerfiles #303

Workflow file for this run

name: "update_dockerfiles"
# updating the image code and pushing to the local registry
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
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }}
- run: pip3 install --upgrade pip
- run: pip3 install --upgrade lastversion
- run: tools/install_manifest-tool.sh
- run: tools/environment_init.sh
- run: ./update.sh
- run: git status
- run: git diff versions.json
- name: Check if versions.json changed
id: version_check
run: |
if git diff --name-only | grep 'versions.json'; then
echo "versions_changed=true" >> $GITHUB_ENV
echo "versions_changed=true"
# Generate changed versions list
echo "versions_changed_list=$(./tools/get_versions_changes.sh)" >> $GITHUB_ENV
echo "versions_changed_list=$(./tools/get_versions_changes.sh)"
# Generate branch name with date and time
echo "BRANCH_NAME=updates/$(date +'%Y%m%d_%H%M')" >> $GITHUB_ENV
echo "BRANCH_NAME=updates/$(date +'%Y%m%d_%H%M')"
else
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' && steps.check_prs.outputs.create_pr == 'true'
id: create-pr
uses: peter-evans/create-pull-request@v6
with:
committer: GitHub <[email protected]>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
commit-message: '🤖 Bump versions: ${{ env.versions_changed_list }}'
title: '🤖 Bump versions: ${{ env.versions_changed_list }}'
body: |
## 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.
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."