45 lines
1014 B
YAML
45 lines
1014 B
YAML
name: Build and Push to GHCR
|
|
|
|
on:
|
|
push:
|
|
branches: [ main ]
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: 'stable'
|
|
|
|
- name: Run tests
|
|
run: go test -v ./...
|
|
|
|
- name: Build
|
|
run: go build -o app ./cmd/app
|
|
|
|
- name: Log in to GHCR
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: git.gocommunity.ru
|
|
username: ${{ secrets.USER }}
|
|
password: ${{ secrets.TOKEN }}
|
|
|
|
- name: Build and push Docker image
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
push: true
|
|
tags: |
|
|
git.gocommunity.ru/${{ github.repository }}:latest
|
|
git.gocommunity.ru/${{ github.repository }}:${{ github.sha }}
|
|
labels: |
|
|
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }} |