chore: update kujira lcds (#144) #127
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 and push latest docker image | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
build-and-push-latest-docker-image: | |
strategy: | |
matrix: | |
os: | |
- ubuntu-20.04 | |
runs-on: ${{ matrix.os }} | |
permissions: | |
id-token: write | |
contents: read | |
env: | |
REPOSITORY: axelarscan-api | |
IMAGE_TAG: ${{ github.sha }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: fetch tags | |
run: | | |
git fetch --unshallow | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-region: us-east-2 | |
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/ghwf-${{ github.event.repository.name }} | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v2 | |
- name: check if an image already build on same commit hash | |
id: image-tag-check | |
run: | | |
app_version="v$(jq -r .version package.json)" | |
if [ ${{ github.ref }} != 'refs/heads/main' ]; then | |
app_version="${app_version}-dev_${GITHUB_RUN_NUMBER}.${GITHUB_RUN_ATTEMPT}" | |
fi | |
image_tag_exists=$(aws ecr batch-get-image --repository-name ${REPOSITORY} --image-ids "imageTag=${app_version}" | jq '.images | length') | |
echo "image_tag_exists=${image_tag_exists}" >> $GITHUB_OUTPUT | |
echo "IMAGE_TAG=${app_version}" >> $GITHUB_ENV | |
- name: Build docker image | |
if: steps.image-tag-check.outputs.image_tag_exists == 0 | |
run: | | |
docker build --platform linux/amd64 -t axelarscan/axelarscan-api . | |
- name: Push to ECR | |
if: steps.image-tag-check.outputs.image_tag_exists == 0 | |
env: | |
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
run: | | |
docker image tag axelarscan/axelarscan-api "${ECR_REGISTRY}/${REPOSITORY}:${IMAGE_TAG}" | |
docker push "${ECR_REGISTRY}/${REPOSITORY}:${IMAGE_TAG}" |