-
Notifications
You must be signed in to change notification settings - Fork 4
64 lines (55 loc) · 2.09 KB
/
build-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
57
58
59
60
61
62
63
64
name: Build - publish
on:
push:
branches:
- main
workflow_dispatch:
inputs:
docker_tag_suffix:
description: "Enter a Docker Tag suffix (e.g dev)\nSuffixed images will not be auto-deployed"
required: false
type: string
env:
ECR_REPOSITORY_URL: 673156464838.dkr.ecr.us-west-2.amazonaws.com
ECR_REPOSITORY_NAME: gpt-survey-summarizer
jobs:
build-publish:
name: Build and Publish Docker Image
runs-on: minafoundation-default-runners
steps:
- name: 📥 Checkout
uses: actions/checkout@v4
- name: 🦀 Get application version from package.json
id: application-version
uses: martinbeentjes/[email protected]
- name: 🏷️ Generate Tag
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
if [ "${{ github.event.inputs.docker_tag_suffix }}" != "" ]; then
echo "TAG=${{ steps.application-version.outputs.current-version }}-${{ github.event.inputs.docker_tag_suffix }}" >> $GITHUB_ENV
else
echo "TAG=${{ steps.application-version.outputs.current-version }}" >> $GITHUB_ENV
fi
elif [ "${{ github.event_name }}" == "push" ] && [ -n "${{ github.event.ref }}" ]; then
echo "TAG=${{ steps.application-version.outputs.current-version }}" >> $GITHUB_ENV
else
echo "Invalid event. Exiting..."
exit 1
fi
- name: 🔑 ECR Login
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- 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 and Push Docker
uses: mr-smithers-excellent/docker-build-push@v6
if: steps.checktag.outputs.tag == 'not found'
with:
image: ${{ env.ECR_REPOSITORY_NAME }}
registry: ${{ env.ECR_REPOSITORY_URL }}
tags: ${{ env.TAG }}