Skip to content

ci: change container registry to private ecr #12

ci: change container registry to private ecr

ci: change container registry to private ecr #12

Workflow file for this run

name: Continuous Integration
on:
pull_request:
push:
branches:
- main
tags: ["**"]
permissions:
id-token: write
contents: read
packages: write
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache-dependency-path: go.sum
- name: Run test
run: make _test
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache-dependency-path: go.sum
- name: Run lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.61
args: --timeout=5m
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache-dependency-path: go.sum
- name: Build
env:
GOOS: linux
GOARCH: arm64
run: make _build
build-and-push-image:
if: github.event_name == 'push'
runs-on: ubuntu-latest
needs:
- test
- lint
- build
steps:
- uses: actions/checkout@v4
- name: Get image tag
id: image-tag
run: |
if [[ "${{ github.ref }}" =~ ^refs/tags/ ]] ; then
echo tag=$(echo "$GITHUB_REF_NAME" ) >> $GITHUB_OUTPUT
else
echo tag=$(echo ${{ github.sha }} | cut -c1-10) >> $GITHUB_OUTPUT
fi
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_GITHUB_ACTIONS_ROLE }}
role-session-name: ${{ github.event.repository.name }}-actions
aws-region: ap-northeast-2
- name: ECR login
id: ecr-login
uses: aws-actions/amazon-ecr-login@v2
- name: Get current time
id: time
shell: sh
run: |
echo current_time=$(TZ=Asia/Seoul date +'%Y-%m-%dT%H:%M:%S%z') >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
platforms: linux/arm64
- name: Build image and push to ECR
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.ecr-login.outputs.registry }}/${{ github.event.repository.name }}:${{ steps.image-tag.outputs.tag }}
platforms: linux/arm64
build-args: |
BUILD_VERSION=${{ github.ref_name }}
BUILD_COMMIT=${{ github.sha }}
BUILD_TIME=${{ steps.time.outputs.current_time }}