Skip to content

feat: include git version info in container (#543) #147

feat: include git version info in container (#543)

feat: include git version info in container (#543) #147

on:
push:
branches:
- master
name: release-please
jobs:
release-please:
runs-on: ubuntu-latest
outputs:
release_created: ${{ steps.release.outputs.release_created }}
steps:
- uses: google-github-actions/release-please-action@v3
id: release
with:
release-type: node
token: ${{ secrets.GITHUB_TOKEN }}
publish-release:
needs: release-please
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
packages: write
if: ${{ needs.release-please.outputs.release_created }}
steps:
- uses: linz/action-typescript@v3
- name: Setup GIT version
id: version
run: |
GIT_VERSION=$(git describe --tags --always --match 'v*')
GIT_VERSION_MAJOR=$(echo $GIT_VERSION | cut -d. -f1)
GIT_VERSION_MAJOR_MINOR=$(echo $GIT_VERSION | cut -d. -f1,2)
echo "version=${GIT_VERSION}" >> $GITHUB_OUTPUT
echo "version_major=${GIT_VERSION_MAJOR}" >> $GITHUB_OUTPUT
echo "version_major_minor=${GIT_VERSION_MAJOR_MINOR}" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ github.repository }}
labels: |
org.opencontainers.image.version=${{ steps.version.outputs.version }}
- name: Build and container
uses: docker/build-push-action@v4
with:
context: .
tags: base
push: false
labels: ${{ steps.meta.outputs.labels }}
build-args: |
GIT_HASH=${{ github.sha }}
GIT_VERSION=${{ steps.version.outputs.version }}
GITHUB_RUN_ID=${{ github.run_id}}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Publish Containers to GHCR
run: |
docker tag base ghcr.io/${{ github.repository }}:latest
docker tag base ghcr.io/${{ github.repository }}:${{ steps.version.outputs.version_major }}
docker tag base ghcr.io/${{ github.repository }}:${{ steps.version.outputs.version_major_minor }}
docker tag base ghcr.io/${{ github.repository }}:${{ steps.version.outputs.version }}
docker push --all-tags ghcr.io/${{ github.repository }}
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-region: ap-southeast-2
mask-aws-account-id: true
role-to-assume: ${{ secrets.AWS_CI_ROLE }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Publish Containers to ECR
run: |
docker tag base ${{ steps.login-ecr.outputs.registry }}/eks:argo-tasks-latest
docker tag base ${{ steps.login-ecr.outputs.registry }}/eks:argo-tasks-${{ steps.version.outputs.version_major }}
docker tag base ${{ steps.login-ecr.outputs.registry }}/eks:argo-tasks-${{ steps.version.outputs.version_major_minor }}
docker tag base ${{ steps.login-ecr.outputs.registry }}/eks:argo-tasks-${{ steps.version.outputs.version }}
docker push --all-tags ${{ steps.login-ecr.outputs.registry }}/eks