name: Update Docker Image Tags on: schedule: - cron: '0 2 * * 1' # 毎週月曜日午前2時 workflow_dispatch: jobs: update-tags: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v3 - name: Check for new nginx version id: nginx run: | CURRENT=$(grep -A2 "nginx:" values.yaml | grep "tag:" | sed 's/.*tag: "\(.*\)"/\1/') LATEST=$(curl -s https://registry.hub.docker.com/v2/repositories/library/nginx/tags?page_size=100 | \ jq -r '.results[].name' | grep -E '^[0-9]+\.[0-9]+\.[0-9]+-alpine-perl$' | sort -V | tail -1) echo "current=$CURRENT" >> $GITHUB_OUTPUT echo "latest=$LATEST" >> $GITHUB_OUTPUT - name: Check for new wordpress version id: wordpress run: | CURRENT=$(grep -A2 "wordpress:" values.yaml | grep "tag:" | sed 's/.*tag: "\(.*\)"/\1/') LATEST=$(curl -s https://registry.hub.docker.com/v2/repositories/library/wordpress/tags?page_size=100 | \ jq -r '.results[].name' | grep -E '^[0-9]+\.[0-9]+\.[0-9]+-php[0-9]+\.[0-9]+-fpm-alpine$' | sort -V | tail -1) echo "current=$CURRENT" >> $GITHUB_OUTPUT echo "latest=$LATEST" >> $GITHUB_OUTPUT - name: Update values.yaml if: steps.nginx.outputs.current != steps.nginx.outputs.latest || steps.wordpress.outputs.current != steps.wordpress.outputs.latest run: | sed -i 's/tag: "${{ steps.nginx.outputs.current }}"/tag: "${{ steps.nginx.outputs.latest }}"/' values.yaml sed -i 's/tag: "${{ steps.wordpress.outputs.current }}"/tag: "${{ steps.wordpress.outputs.latest }}"/' values.yaml - name: Create Pull Request uses: peter-evans/create-pull-request@v5 with: token: ${{ secrets.GITHUB_TOKEN }} commit-message: | chore: update docker image tags - nginx: ${{ steps.nginx.outputs.current }} → ${{ steps.nginx.outputs.latest }} - wordpress: ${{ steps.wordpress.outputs.current }} → ${{ steps.wordpress.outputs.latest }} title: 'chore: update docker image tags' body: | ## Docker Image Updates | Image | Current | Latest | |-------|---------|--------| | nginx | `${{ steps.nginx.outputs.current }}` | `${{ steps.nginx.outputs.latest }}` | | wordpress | `${{ steps.wordpress.outputs.current }}` | `${{ steps.wordpress.outputs.latest }}` | This PR was automatically generated. branch: update-docker-images delete-branch: true