Skip to content

Commit cec45db

Browse files
committed
change container registry to private ecr
1 parent cc60237 commit cec45db

File tree

1 file changed

+22
-24
lines changed

1 file changed

+22
-24
lines changed

.github/workflows/ci.yaml

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ on:
66
branches:
77
- exp
88
- main
9-
- feature/**
109
tags: ["**"]
1110

1211
permissions:
@@ -64,7 +63,7 @@ jobs:
6463
run: make _build
6564

6665
build-and-push-image:
67-
if: github.ref == 'refs/heads/exp' || startsWith(github.ref, 'refs/heads/feature/') || startsWith(github.ref, 'refs/tags/')
66+
if: github.ref == 'refs/heads/exp' || startsWith(github.ref, 'refs/tags/')
6867
runs-on: ubuntu-latest
6968
needs:
7069
- test
@@ -73,29 +72,28 @@ jobs:
7372
steps:
7473
- uses: actions/checkout@v4
7574

76-
- name: Get 10 length commit sha
77-
if: github.ref == 'refs/heads/exp' || startsWith(github.ref, 'refs/heads/feature/')
78-
id: short-sha
75+
- name: Get image tag
76+
id: image-tag
7977
run: |
80-
echo value=$(echo ${{ github.sha }} | cut -c1-10) >> $GITHUB_OUTPUT
81-
82-
- name: Log in to the Container registry
83-
uses: docker/login-action@v3
78+
if [[ "${{ github.ref }}" == 'refs/heads/exp' ]] ; then
79+
echo tag=$(echo ${{ github.sha }} | cut -c1-10) >> $GITHUB_OUTPUT
80+
elif [[ "${{ github.ref }}" == 'refs/tags/' ]] ; then
81+
echo tag=$(echo "$GITHUB_REF_NAME" ) >> $GITHUB_OUTPUT
82+
else
83+
echo "Image tag cannot be set"
84+
exit 1
85+
fi
86+
87+
- name: Configure AWS Credentials
88+
uses: aws-actions/configure-aws-credentials@v4
8489
with:
85-
registry: ghcr.io
86-
username: ${{ github.actor }}
87-
password: ${{ secrets.GITHUB_TOKEN }}
90+
role-to-assume: ${{ secrets.AWS_GITHUB_ACTIONS_ROLE }}
91+
role-session-name: ${{ github.event.repository.name }}-actions
92+
aws-region: ap-northeast-2
8893

89-
- name: Docker meta
90-
id: meta
91-
uses: docker/metadata-action@v5
92-
with:
93-
images: |
94-
ghcr.io/${{ github.repository }}
95-
tags: |
96-
type=raw,priority=100,prefix=exp-,value=${{ steps.short-sha.outputs.value }},enable=${{ startsWith(github.ref, 'refs/heads/exp') }}
97-
type=raw,priority=100,prefix=feature-,value=${{ steps.short-sha.outputs.value }},enable=${{ startsWith(github.ref, 'refs/heads/feature/') }}
98-
type=ref,priority=600,event=tag,enable=${{ startsWith(github.ref, 'refs/tags/') }}
94+
- name: ECR login
95+
id: ecr-login
96+
uses: aws-actions/amazon-ecr-login@v2
9997

10098
- name: Get current time
10199
id: time
@@ -108,12 +106,12 @@ jobs:
108106
with:
109107
platforms: linux/arm64
110108

111-
- name: Build image and push to GitHub Container Registry
109+
- name: Build image and push to ECR
112110
uses: docker/build-push-action@v6
113111
with:
114112
context: .
115113
push: true
116-
tags: ${{ steps.meta.outputs.tags }}
114+
tags: ${{ steps.ecr-login.outputs.registry }}/${{ github.event.repository.name }}:${{ steps.image-tag.outputs.tag }}
117115
platforms: linux/arm64
118116
build-args: |
119117
BUILD_VERSION=${{ github.ref_name }}

0 commit comments

Comments
 (0)