accounts-profiles-endpoint/.github/workflows/build.yml

58 lines
1.4 KiB
YAML
Raw Normal View History

2023-11-17 09:24:54 +05:30
name: Build
2023-11-17 10:09:45 +05:30
on:
push:
branches:
- master
env:
2024-09-22 18:46:25 +05:30
go_version: 1.23
2023-11-17 09:24:54 +05:30
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
2023-11-17 10:09:45 +05:30
- name: Setup Go ${{ env.go_version }}
2024-09-22 18:46:25 +05:30
uses: actions/setup-go@v5
2023-11-17 09:24:54 +05:30
with:
2023-11-17 10:09:45 +05:30
go-version: ${{ env.go_version }}
2023-11-17 09:24:54 +05:30
cache-dependency-path: go.sum
- name: Install dependencies
run: go get .
- name: Build
run: go build ./...
2023-11-17 10:09:45 +05:30
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
2024-09-22 18:46:25 +05:30
- id: version
name: Set up build version
run: |
if [[ $GITHUB_REF_TYPE == "tag" ]]; then
VERSION=${GITHUB_REF#refs/tags/}
else
BRANCH_NAME=${GITHUB_REF#refs/heads/}
SHORT_SHA=$(git rev-parse --short $GITHUB_SHA)
VERSION="${BRANCH_NAME}-${SHORT_SHA}"
fi
echo "### Version: $VERSION" >> $GITHUB_STEP_SUMMARY
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
2023-11-17 10:09:45 +05:30
- name: Build and push
2024-09-22 18:46:25 +05:30
uses: docker/build-push-action@v6
2023-11-17 10:09:45 +05:30
with:
push: true
tags: ghcr.io/${{ github.repository }}:latest
2024-09-22 18:46:25 +05:30
build-args: |
VERSION=${{ steps.version.outputs.version }}
COMMIT=${{ github.sha }}