This repository has been archived by the owner on Apr 16, 2024. It is now read-only.
forked from slashdevops/idp-scim-sync
-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (90 loc) · 3.26 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
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:
GO_VERSION: 1.19
AWS_REGION: us-east-1
permissions:
id-token: write
contents: read
jobs:
publish_container_images:
name: Publish Container Images
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
id: go
- name: Check out code
uses: actions/checkout@v3
- id: go-cache-paths
run: |
echo "::set-output name=go-build::$(go env GOCACHE)"
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
- name: Go Build Cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
- name: Go Mod Cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
- name: Git Current branch name (Version)
run: |
echo ${{ github.ref_name }}
- name: Docker Version
run: docker version
- uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Show workspace files
run: tree .
- name: Build container images
run: make container-build GIT_VERSION=${{ github.ref_name }}
- name: Show local 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: make container-publish-docker GIT_VERSION=${{ github.ref_name }}
- 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: make container-publish-github GIT_VERSION=${{ github.ref_name }}
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@master
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
# not supported public repos yet: https://github.com/aws-actions/amazon-ecr-login/issues/116
# - name: Logging in AWS ECR Public Repository
# id: login-ecr
# uses: aws-actions/amazon-ecr-login@v1
- name: Publish Images in GitHub Packages
run: make container-publish-aws-ecr GIT_VERSION=${{ github.ref_name }}