Skip to content

Commit

Permalink
chore: add action to update base image (#33)
Browse files Browse the repository at this point in the history
* chore: add action to update base image

* rename action

* update action
  • Loading branch information
ravisingal authored Jul 29, 2024
1 parent 467c48c commit 132439e
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/update-docker-args.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
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 }}

0 comments on commit 132439e

Please sign in to comment.