-
Notifications
You must be signed in to change notification settings - Fork 0
34 lines (31 loc) · 1.2 KB
/
ci.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
name: CI
on:
push:
branches:
- master
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
jobs:
tests:
runs-on: ubuntu-latest
uses: ./.github/workflows/checks.yml # use the callable tests job to run tests
docker-build:
needs: [tests]
runs-on: ubuntu-latest
env:
BUILDER_IMAGE: golang:1.21-alpine3.18
steps:
- name: Git clone
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }} # Checkout Pull Request HEAD commit instead of the default Pull Request merge commit.
- name: Log into Github registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Docker build
run: |
PULL_REQUEST_ID=${{ github.event.number }}
export COMMIT="$(git log -1 --pretty=format:'%h')"
export VERSION="$(date -d @$(git log -n1 --format=%at) +'v%-y.%-m.%-d')-${COMMIT}${PULL_REQUEST_ID:+-PR-$PULL_REQUEST_ID}"
docker build --build-arg BUILDER_IMAGE=${BUILDER_IMAGE} --build-arg VERSION=${VERSION} --build-arg COMMIT=${COMMIT} -t ghcr.io/skeleton:$VERSION .
docker push ghcr.io/skeleton:$VERSION