Skip to content

Merge pull request #688 from kids-first/update-tag-version-for-docker #2

Merge pull request #688 from kids-first/update-tag-version-for-docker

Merge pull request #688 from kids-first/update-tag-version-for-docker #2

Workflow file for this run

name: Build and Publish Image
on:
push:
branches:
- "master"
release:
types: [published]
permissions:
contents: read
id-token: write
jobs:
build-publish-prd-image:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'release' }}
steps:
- uses: actions/checkout@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: "Build and Publish"
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ghcr.io/kids-first/kf-api-dataservice/kf-api-dataservice:${{ github.ref_name }}
build-publish-dev-image:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' }}
steps:
- uses: actions/checkout@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set git tag and SHA
run: |
VERSION=$(git tag --sort=committerdate | grep -E '[0-9]' | tail -1 | cut -b 1-7)
SHORT_SHA=${GITHUB_SHA:0:7}
TAG="${VERSION}-${SHORT_SHA}"
echo "TAG=${TAG}" >> $GITHUB_ENV
- name: "Build and Publish"
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ghcr.io/kids-first/kf-api-dataservice/kf-api-dataservice:dev-release-${{ env.TAG }}