name: Build on: push: branches: - master env: go_version: 1.23 jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Setup Go ${{ env.go_version }} uses: actions/setup-go@v5 with: go-version: ${{ env.go_version }} cache-dependency-path: go.sum - name: Install dependencies run: go get . - name: Build run: go build ./... - name: Log in to the Container registry uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - 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" - name: Build and push uses: docker/build-push-action@v6 with: push: true tags: ghcr.io/${{ github.repository }}:latest build-args: | VERSION=${{ steps.version.outputs.version }} COMMIT=${{ github.sha }}