Skip to content

Update Docker Args

Update Docker Args #12

name: Update Docker Args
on:
schedule:
- cron: 0 1 * * 1
workflow_dispatch:
jobs:
update-docker-args:
runs-on: ubuntu-22.04
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Update Docker Args
shell: bash
id: args
run: |
BASE_IMAGE="gcr.io/distroless/cc-debian12"
BASE_IMAGE_TAG="debug"
BASE_IMAGE_DIGEST=$(gcloud container images list-tags $BASE_IMAGE --format json | jq --arg tag "$BASE_IMAGE_TAG" -r '.[] | {digest: .digest, tag: .tags[]} | select(.tag == $tag) | .digest')
if [ -n "$BASE_IMAGE_DIGEST" ]; then
echo -n "${BASE_IMAGE}:${BASE_IMAGE_TAG}@${BASE_IMAGE_DIGEST}" > java-11/base.image
echo -n "${BASE_IMAGE}:${BASE_IMAGE_TAG}@${BASE_IMAGE_DIGEST}" > java-21/base.image
echo "digest=${BASE_IMAGE_DIGEST}" >> $GITHUB_OUTPUT
else
echo "digest=null" >> $GITHUB_OUTPUT
fi
- name: Create Pull Request
if: steps.args.outputs.digest != 'null'
uses: peter-evans/create-pull-request@v6
id: create-pull-request
with:
token: ${{ secrets.GITHUB_TOKEN }}
title: Update docker args (Automated)
body: |
# Autogenerated docker args update:
digest: ${{ steps.args.outputs.digest }}
commit-message: Update docker args
delete-branch: true
branch-suffix: timestamp
- name: Enable Pull Request Automerge
if: steps.args.outputs.digest != 'null'
uses: peter-evans/enable-pull-request-automerge@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
pull-request-number: ${{ steps.create-pull-request.outputs.pull-request-number }}
merge-method: squash
# - name: Approve Pull Request
# if: steps.args.outputs.digest != 'null'
# uses: juliangruber/approve-pull-request-action@v2
# with:
# github-token: ${{ secrets.GITHUB_TOKEN }}
# number: ${{ steps.create-pull-request.outputs.pull-request-number }}