Skip to content

Commit

Permalink
feat: add build package workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
bookpanda committed Jan 4, 2024
1 parent 719585d commit 132a49b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 12 deletions.
44 changes: 33 additions & 11 deletions .github/workflows/build-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
- beta
- dev

env:
IMAGE_NAME: ghcr.io/${{ github.repository }}
IMAGE_TAG: ${{ github.sha }}

jobs:
test:
runs-on: ubuntu-latest
Expand All @@ -18,7 +22,6 @@ jobs:
with:
go-version: 1.21
check-latest: true
cache: true

- name: Download dependencies
run: go mod download
Expand All @@ -36,21 +39,40 @@ jobs:
go tool cover -func="./coverage.out"
build:
name: Build
runs-on: ubuntu-latest
needs:
- test

permissions:
contents: read
packages: write

outputs:
BRANCH: ${{ steps.branch.outputs.BRANCH }}

steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Checkout
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build Docker image
id: docker_build

- name: Set branch
id: branch
run: |
echo "::set-output name=BRANCH::${GITHUB_REF#refs/heads/}"
- name: Log in to the Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and Push Docker Image
uses: docker/build-push-action@v2
with:
context: .
push: false
tags: test
push: true
tags: ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }},${{ env.IMAGE_NAME }}:latest
cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache
cache-to: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache,mode=max
1 change: 0 additions & 1 deletion .github/workflows/run-unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ jobs:
with:
go-version: 1.21
check-latest: true
cache: true

- name: Download dependencies
run: go mod download
Expand Down

0 comments on commit 132a49b

Please sign in to comment.