-
Notifications
You must be signed in to change notification settings - Fork 11
43 lines (37 loc) · 1.51 KB
/
publish_dockerfile.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
name: Publish Dockerfile
on:
push:
branches:
- main
jobs:
build:
runs-on: buildjet-16vcpu-ubuntu-2204
steps:
- uses: actions/checkout@v3
# Count the number of commits on the current branch
- name: Count commits
run: echo "COMMIT_COUNT=$(git rev-list --count HEAD)" >> $GITHUB_ENV
# Grab the short SHA from Git to use in tagging
- name: Grab Github short SHA
run: |
echo "SHORT_SHA=$(git rev-parse --short "$GITHUB_SHA")" >> $GITHUB_ENV
# Set up AWS CLI with credentials
- name: Set up AWS CLI
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.ECR_HELIUS_PROD_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.ECR_HELIUS_PROD_AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-2
- name: Login to Amazon Public ECR
run: |
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws
# Build and push Docker image using matrix for different Dockerfiles
- name: Build and Push Docker image
run: |
IMAGE_TAG=${{ github.run_number }}-${{ env.SHORT_SHA }}
IMAGE_LOCATION=public.ecr.aws/f7o9l7p1/photon
IMAGE_URI=$IMAGE_LOCATION:$IMAGE_TAG
docker build . -t $IMAGE_URI -t $IMAGE_LOCATION:latest
docker push $IMAGE_URI
docker push $IMAGE_LOCATION:latest
echo "Image pushed: $IMAGE_URI"