Skip to content

Commit

Permalink
Adds app version as image label
Browse files Browse the repository at this point in the history
  • Loading branch information
djperrefort committed Dec 5, 2023
1 parent bd3000e commit d97a10f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/Build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Get application version
id: version
run: echo "version=$(echo ${{github.ref}} | sed 's/refs\/tags\/v//')" >> $GITHUB_OUTPUT

- name: Install Poetry
if: startsWith(github.ref, 'refs/tags')
uses: snok/install-poetry@v1
Expand All @@ -29,6 +33,7 @@ jobs:
uses: docker/build-push-action@v5
with:
context: .
labels: keystone-api-version=${{ steps.version.outputs.version }}
tags: test-image:latest
outputs: type=docker,dest=/tmp/test-image.tar

Expand Down
22 changes: 12 additions & 10 deletions .github/workflows/Publish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish Docker Image
name: Publish Docker

on:
workflow_call:
Expand All @@ -12,15 +12,6 @@ jobs:
name: Publish Image

steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Fetch image artifact
uses: actions/download-artifact@v3
Expand All @@ -31,6 +22,17 @@ jobs:
- name: Load image
run: docker load --input /tmp/test-image.tar

- name: Get application version
id: version
run: echo "version=$(docker inspect --format='{{index .Config.Labels "keystone-api-version"}}' test-image)" >> $GITHUB_OUTPUT

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Publish image
uses: docker/build-push-action@v5
with:
Expand Down

0 comments on commit d97a10f

Please sign in to comment.