Skip to content
41 changes: 41 additions & 0 deletions .github/workflows/docker-build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ jobs:
# https://github.com/actions/checkout
uses: actions/checkout@v4

- name: Protector Metadata
shell: bash
run: >
jq -n \
--arg repo ${{ github.repository }} \
--arg branch ${{ github.ref_name }} \
--arg revision ${{ github.sha }} \
--arg buildDate "$(date --iso-8601=seconds --utc)" \
'{gitRepo: $repo, gitBranch: $branch, gitRevision: $revision, buildDate: $buildDate}' > protector_metadata.json

- name: Login to Docker Hub
# https://github.com/docker/login-action
uses: docker/login-action@v3
Expand Down Expand Up @@ -73,6 +83,7 @@ jobs:
file: ${{ inputs.DOCKERFILE_PATH }}
tags: ${{ steps.meta-production.outputs.tags }}
build-args: ${{ secrets.BUILD_ARGS }}
context: .

- name: Sync README with Docker Hub description
if: ${{ github.ref_name == env.LATEST_TAG }}
Expand All @@ -89,6 +100,20 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout GitHub repository
# https://github.com/actions/checkout
uses: actions/checkout@v4

- name: Protector Metadata
shell: bash
run: >
jq -n \
--arg repo ${{ github.repository }} \
--arg branch ${{ github.ref_name }} \
--arg revision ${{ github.sha }} \
--arg buildDate "$(date --iso-8601=seconds --utc)" \
'{gitRepo: $repo, gitBranch: $branch, gitRevision: $revision, buildDate: $buildDate}' > protector_metadata.json

- name: Login to Docker Hub
# https://github.com/docker/login-action
uses: docker/login-action@v3
Expand Down Expand Up @@ -119,6 +144,7 @@ jobs:
file: ${{ inputs.DOCKERFILE_PATH }}
tags: ${{ steps.meta-pr.outputs.tags }}
build-args: ${{ secrets.BUILD_ARGS }}
context: .

delete-pr-image:
if: ${{ github.event_name == 'pull_request' && github.event.action == 'closed' }}
Expand All @@ -138,6 +164,20 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout GitHub repository
# https://github.com/actions/checkout
uses: actions/checkout@v4

- name: Protector Metadata
shell: bash
run: >
jq -n \
--arg repo ${{ github.repository }} \
--arg branch ${{ github.ref_name }} \
--arg revision ${{ github.sha }} \
--arg buildDate "$(date --iso-8601=seconds --utc)" \
'{gitRepo: $repo, gitBranch: $branch, gitRevision: $revision, buildDate: $buildDate}' > protector_metadata.json

- name: Login to Docker Hub
# https://github.com/docker/login-action
uses: docker/login-action@v3
Expand Down Expand Up @@ -168,6 +208,7 @@ jobs:
file: ${{ inputs.DOCKERFILE_PATH }}
tags: ${{ steps.meta-branch.outputs.tags }}
build-args: ${{ secrets.BUILD_ARGS }}
context: .

delete-branch-image:
if: ${{ github.event_name == 'delete' && github.event.ref_type == 'branch' && startsWith(github.event.ref, 'preview/') }}
Expand Down