-
-
Notifications
You must be signed in to change notification settings - Fork 20
90 lines (73 loc) · 2.33 KB
/
container-image.yml
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
name: "Container Image"
on:
workflow_call:
secrets:
DOCKER_HUB_TOKEN:
required: true
DOCKER_HUB_USER:
required: true
GH_PAT:
required: true
GH_USER:
required: true
AWS_OIDC_ROLE_TO_ASSUME:
required: true
workflow_dispatch:
env:
AWS_REGION: us-east-1
permissions:
id-token: write
contents: read
jobs:
build_publish_container_images:
name: Build and Publish Container Images
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Go 1.x
id: go
uses: actions/setup-go@v5
with:
go-version-file: ./go.mod
- name: Go version
run: |
go version
- name: Git Current branch name (Version)
run: |
echo ${{ github.ref_name }}
- name: Docker Version
run: |
docker version
- name: Build container images
run: |
GIT_VERSION=${{ github.ref_name }} make container-build
- name: Show container images
run: |
docker images
- name: Logging in Docker Hub
run: |
echo ${{ secrets.DOCKER_HUB_TOKEN }} | docker login -u ${{ secrets.DOCKER_HUB_USER }} --password-stdin
- name: Publish Images in Docker Hub
run: |
GIT_VERSION=${{ github.ref_name }} make container-publish-docker
- name: Logging in GitHub Registry
run: |
echo ${{ secrets.GH_PAT }} | docker login ghcr.io -u ${{ secrets.GH_USER }} --password-stdin
- name: Publish Images in GitHub Registry
run: |
GIT_VERSION=${{ github.ref_name }} make container-publish-github
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_OIDC_ROLE_TO_ASSUME }}
role-session-name: publish-ecr-public-images
aws-region: ${{ env.AWS_REGION }}
- name: Logging in AWS ECR Public Repository
env:
AWS_REGION: ${{ env.AWS_REGION }}
run: |
aws ecr-public get-login-password --region $AWS_REGION | docker login --username AWS --password-stdin public.ecr.aws
- name: Publish Images in GitHub Packages
run: |
GIT_VERSION=${{ github.ref_name }} make container-publish-aws-ecr