-
Notifications
You must be signed in to change notification settings - Fork 0
56 lines (53 loc) · 2.04 KB
/
publish.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
name: Publish
on:
push:
tags:
- '*'
workflow_dispatch:
inputs:
docker_tag_prefix:
description: "Enter the Docker Tag Prefix (e.g adhoc-test)"
required: true
type: string
env:
ECR_REPOSITORY_URL: 673156464838.dkr.ecr.us-west-2.amazonaws.com
ECR_REPOSITORY_NAME: mina-transactions-generator
DOCKER_TAG_PREFIX: ${{ github.event.inputs.docker_tag_prefix }}
# This allows a subsequently queued workflow run to interrupt previous runs
concurrency:
group: '${{ github.workflow }} @ ${{ github.head_ref || github.ref }}'
cancel-in-progress: true
jobs:
build-docker-image:
name: Build and Push Docker Image
runs-on: minafoundation-default-runners
steps:
- name: 📥 Checkout
uses: actions/checkout@v3
- name: 🏷️ Generate Tag
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
PREFIX=${{ env.DOCKER_TAG_PREFIX }}
elif [ "${{ github.event_name }}" == "push" ] && [ -n "${{ github.event.ref }}" ]; then
PREFIX=$(basename ${{ github.ref }})
else
echo "Invalid event. Exiting..."
exit 1
fi
echo "TAG=$PREFIX-$(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_ENV
- name: 🔑 ECR Login
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: 🔍 Check if Tag already exists
id: checktag
uses: tyriis/docker-image-tag-exists@main
with:
registry: ${{ env.ECR_REPOSITORY_URL}}
repository: ${{ env.ECR_REPOSITORY_NAME }}
tag: ${{ env.TAG }}
- name: 🛠️ Build Mina Transactions Generator Docker Image
if: steps.checktag.outputs.tag == 'not found'
run: DOCKER_BUILDKIT=1 docker build -t ${{ env.ECR_REPOSITORY_URL}}/${{ env.ECR_REPOSITORY_NAME }}:${{ env.TAG }} .
- name: 🚚 Push Mina Transactions Generator Docker Image
if: steps.checktag.outputs.tag == 'not found'
run: docker push ${{ env.ECR_REPOSITORY_URL}}/${{ env.ECR_REPOSITORY_NAME }}:${{ env.TAG }}