refactor: add a context #1032
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
on: [push] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
contents: read | |
packages: write | |
steps: | |
- uses: linz/action-typescript@v3 | |
- name: Setup tags | |
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 push | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
tags: argo-tasks | |
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: Log in to registry | |
if: ${{(github.ref == 'refs/heads/master') && !(startsWith(github.event.head_commit.message, 'release:'))}} | |
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin | |
- name: Publish Containers to GHCR | |
if: ${{(github.ref == 'refs/heads/master') && !(startsWith(github.event.head_commit.message, 'release:'))}} | |
env: | |
TAG: argo-tasks | |
run: | | |
GIT_VERSION=$(git describe --tags --always --match 'v*') | |
echo "GIT_VERSION=$GIT_VERSION" >> $GITHUB_ENV | |
docker tag ${{ env.TAG }} ghcr.io/linz/${{ env.TAG }}:latest | |
docker tag ${{ env.TAG }} ghcr.io/linz/${{ env.TAG }}:${GIT_VERSION} | |
docker push --all-tags ghcr.io/linz/${{ env.TAG }} | |
- name: Configure AWS Credentials | |
if: ${{(github.ref == 'refs/heads/master') && !(startsWith(github.event.head_commit.message, 'release:'))}} | |
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 | |
if: ${{(github.ref == 'refs/heads/master') && !(startsWith(github.event.head_commit.message, 'release:'))}} | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
- name: Publish Containers to ECR | |
if: ${{(github.ref == 'refs/heads/master') && !(startsWith(github.event.head_commit.message, 'release:'))}} | |
env: | |
REGISTRY: ${{ steps.login-ecr.outputs.registry }}/eks | |
TAG: argo-tasks | |
run: | | |
docker tag ${{ env.TAG}} ${{ env.REGISTRY }}:${{ env.TAG }}-latest | |
docker tag ${{ env.TAG}} ${{ env.REGISTRY }}:${{ env.TAG }}-${{ env.GIT_VERSION }} | |
docker push --all-tags ${{ env.REGISTRY }} |