]> git.lizzy.rs Git - hydra-dragonfire.git/blob - .github/workflows/build.yml
docker build and workflow
[hydra-dragonfire.git] / .github / workflows / build.yml
1 name: build
2
3 on:
4   push:
5     branches:
6       - 'master'
7     tags:
8       - 'v*'
9   pull_request:
10
11 env:
12   REGISTRY: ghcr.io
13   IMAGE_NAME: ${{ github.repository }}
14
15 jobs:
16   build:
17     runs-on: ubuntu-latest
18     timeout-minutes: 10
19
20     steps:
21       - name: Checkout
22         uses: actions/checkout@v3
23         with:
24           fetch-depth: 0
25           submodules: recursive
26
27       - name: Set up Go
28         uses: actions/setup-go@v3.4.0
29         with:
30           go-version: 1.18
31
32       - name: Cache Go modules
33         uses: actions/cache@v3
34         with:
35           path: ~/go/pkg/mod
36           key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
37           restore-keys: |
38             ${{ runner.os }}-go-
39
40       - name: Log in to the Container registry
41         uses: docker/login-action@v2
42         with:
43           registry: ${{ env.REGISTRY }}
44           username: ${{ github.actor }}
45           password: ${{ secrets.GITHUB_TOKEN }}
46
47       - name: Extract metadata (tags, labels) for Docker
48         id: meta
49         uses: docker/metadata-action@v4
50         with:
51           images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
52
53       - name: Build and push Docker image (master)
54         uses: docker/build-push-action@v3
55         with:
56           context: .
57           push: true
58           tags: ${{ steps.meta.outputs.tags }}
59           labels: ${{ steps.meta.outputs.labels }}