diff --git a/.github/workflows/Build.yml b/.github/workflows/Build.yml index c7afb385..a2c94cfc 100644 --- a/.github/workflows/Build.yml +++ b/.github/workflows/Build.yml @@ -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 @@ -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 diff --git a/.github/workflows/Publish.yml b/.github/workflows/Publish.yml index 6cc4e116..0ea04f64 100644 --- a/.github/workflows/Publish.yml +++ b/.github/workflows/Publish.yml @@ -1,4 +1,4 @@ -name: Publish Docker Image +name: Publish Docker on: workflow_call: @@ -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 @@ -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: