zdravko/.github/workflows/build.yaml

92 lines
2.4 KiB
YAML
Raw Normal View History

2024-02-16 21:31:00 +00:00
name: Build
on:
schedule:
- cron: "0 10 * * *"
push:
branches:
- "main"
2024-02-16 21:31:00 +00:00
tags:
- "v*.*.*"
pull_request:
branches:
- "main"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
2024-06-02 19:56:40 +00:00
- name: Install devbox
2024-06-03 21:38:46 +00:00
uses: jetify-com/devbox-install-action@v0.11.0
with:
enable-cache: true
2024-02-16 21:31:00 +00:00
- name: Login to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/mentos1386/zdravko
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
2024-06-03 19:34:39 +00:00
- name: Setup Golang cache
uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
2024-06-02 19:55:52 +00:00
- name: Build binaries
2024-06-02 19:58:03 +00:00
run: devbox run -- just build-bin
2024-06-02 19:55:52 +00:00
2024-02-16 21:31:00 +00:00
- name: Build and push
uses: docker/build-push-action@v5
with:
2024-02-16 21:33:22 +00:00
file: build/Dockerfile
2024-02-16 21:31:00 +00:00
context: .
push: ${{ github.event_name != 'pull_request' }}
platforms: linux/amd64,linux/arm64
2024-02-16 21:31:00 +00:00
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
2024-02-18 09:38:14 +00:00
deploy:
runs-on: ubuntu-latest
2024-02-18 09:49:28 +00:00
needs: build
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
2024-02-18 09:38:14 +00:00
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install devbox
2024-06-03 21:38:46 +00:00
uses: jetify-com/devbox-install-action@v0.11.0
with:
enable-cache: true
2024-02-18 09:38:14 +00:00
2024-02-19 10:09:31 +00:00
- run: devbox run -- just deploy-fly
2024-02-18 09:38:14 +00:00
if : github.event_name == 'push' && github.ref == 'refs/heads/main'
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}