-
Notifications
You must be signed in to change notification settings - Fork 52
53 lines (44 loc) · 1.22 KB
/
test_and_publish_docker_image.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
on:
push:
branches:
- main
pull_request:
name: ci
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
# The build job will use the .git directory to
# infer the current version to embed in the binary
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version: '1.21'
- run: go build
- run: go test -race ./...
build_and_publish_docker_image:
needs: test
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' }}
steps:
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Get Docker image tags
id: image_tags
run: |
IMAGE=italia/publiccode-crawler
TAGS=${IMAGE}:latest
TAGS="$TAGS,${IMAGE}:${GITHUB_SHA::8}"
echo ::set-output name=tags::${TAGS}
- name: Build and push
uses: docker/build-push-action@v6
with:
build-args: |
BUILDKIT_CONTEXT_KEEP_GIT_DIR=1
push: true
tags: ${{ steps.image_tags.outputs.tags }}