Skip to content

Commit 798104e

Browse files
committed
updated docker push github action
1 parent e378185 commit 798104e

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

.github/workflows/_push-docker.yml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ on:
77
description: 'Whether to push the Docker image'
88
required: true
99
type: boolean
10+
release:
11+
description: 'Whether to push as latest release'
12+
required: false
13+
default: false
14+
type: boolean
1015
version:
1116
description: 'Version to use'
1217
required: false
@@ -18,13 +23,26 @@ on:
1823
description: 'Whether to push the Docker image'
1924
required: true
2025
type: boolean
26+
release:
27+
description: 'Whether to push as latest release'
28+
required: false
29+
default: false
30+
type: boolean
2131
version:
2232
description: 'Version to use'
2333
required: false
2434
default: ''
2535
type: string
2636

2737
jobs:
38+
docker-vars:
39+
runs-on: ubuntu-latest
40+
outputs:
41+
version: ${{ inputs.version || format('{0}-{1}', github.sha, env.COMMIT_TIMESTAMP) }}
42+
steps:
43+
- name: Get Git commit timestamps
44+
run: echo "COMMIT_TIMESTAMP=$(git log -1 --pretty=%ct)" >> $GITHUB_ENV
45+
- run: echo "Exposing env vars"
2846
docker:
2947
runs-on: ubuntu-latest
3048
steps:
@@ -64,7 +82,7 @@ jobs:
6482
load: true
6583
push: ${{ inputs.push }}
6684
tags: |
67-
${{ inputs.push && format('{0}/altairgraphqlapi:latest', secrets.DOCKERHUB_USERNAME) || '' }}
85+
${{ inputs.push && inputs.release && format('{0}/altairgraphqlapi:latest', secrets.DOCKERHUB_USERNAME) || '' }}
6886
${{ inputs.push && inputs.version && format('{0}/altairgraphqlapi:{1}', secrets.DOCKERHUB_USERNAME, inputs.version) || '' }}
69-
${{ inputs.push && format('ghcr.io/{0}/altairgraphqlapi:latest', github.repository_owner) || '' }}
87+
${{ inputs.push && inputs.release && format('ghcr.io/{0}/altairgraphqlapi:latest', github.repository_owner) || '' }}
7088
${{ inputs.push && inputs.version && format('ghcr.io/{0}/altairgraphqlapi:{1}', github.repository_owner, inputs.version) || '' }}

.github/workflows/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ jobs:
4242
uses: ./.github/workflows/_push-docker.yml
4343
with:
4444
push: true
45+
release: true
4546
version: ${{ needs.prepare-release.outputs.release-tag }}
4647
secrets: inherit
4748

0 commit comments

Comments
 (0)