-
Notifications
You must be signed in to change notification settings - Fork 0
44 lines (39 loc) · 1.5 KB
/
build-paul.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
name: Build Paul
on:
push:
# Publish `main` as Docker `latest` image.
branches:
- main
# Publish `v1.2.3` tags as releases.
tags:
- v*
# Run tests for any PRs.
pull_request:
env:
IMAGE_NAME: paul-go
jobs:
assemble:
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v2
- name: Login to github docker Registry
run: docker login ghcr.io -u dylanturn -p ${{ secrets.GITHUB_TOKEN }}
- name: Set the image repo name and tag
id: image_vars
run: |
# Construct an image id and includes the repo.
IMAGE_ID=ghcr.io/${{ github.repository }}/$IMAGE_NAME
# Strip git ref prefix from version.
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name.
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention.
[ "$VERSION" == "main" ] && VERSION=latest
# Set variables that can be used in other steps.
echo ::set-output name=repo::$(echo $IMAGE_ID | awk '{print tolower($0)}')
echo ::set-output name=tag::$(echo $VERSION | awk '{print tolower($0)}')
- name: Build the Docker image
run: docker build . --file Dockerfile --tag ${{steps.image_vars.outputs.repo}}:${{steps.image_vars.outputs.tag}}
- name: Push the Docker image
run: docker push ${{steps.image_vars.outputs.repo}}:${{steps.image_vars.outputs.tag}}