Skip to content

Upgrade gh actions

Upgrade gh actions #7

Workflow file for this run

name: "Build and Release"
on:
push:
tags:
- 'v*'
- 'hotfix*'
jobs:
build_and_push_images:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
env:
RELEASE_VERSION: "${{ github.ref_name }}"
GHCR_REPO: "ghcr.io/ragul28/grpc-event-stream"
strategy:
matrix:
file_tag:
- file: ./build/Dockerfile
service: gateway
context: ./build
- file: ./build/Dockerfile
service: payment-svc
context: ./build
- file: ./build/Dockerfile
service: order-svc
context: ./build
steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ^1.23
- name: Go mod download
run: go mod download
- name: Go Build
run: |
mkdir -p ./build/bin
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o=./build/bin/. ./cmd/${{ matrix.file_tag.service }}/...
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
if: github.event_name != 'pull_request'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
config-inline: |
[worker.oci]
max-parallelism = 3
- name: Matrix Build and push images
uses: docker/[email protected]
with:
context: ${{ matrix.file_tag.context }}
file: ${{ matrix.file_tag.file }}
platforms: linux/amd64
push: ${{ github.event_name != 'pull_request' }}
tags: |
${{ env.GHCR_REPO }}/${{ matrix.file_tag.service }}:${{ env.RELEASE_VERSION }}
build-args: |
SERVICE=${{ matrix.file_tag.service }}
cache-from: type=gha
cache-to: type=gha