66 lines (65 loc) · 2.28 KB
/
publish-docker.yaml
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
54
55
56
57
58
59
60
61
62
63
64
65
66
# publish docker image
# - https://docs.github.com/en/free-pro-team@latest/actions/guides/publishing-docker-images
# - https://github.com/docker/build-push-action
name: Build & Push
on:
workflow_dispatch:
inputs:
version:
description: 'Version (optional)'
required: false
push:
tags:
- v*
jobs:
build_and_push:
name: Build & Push
runs-on: ubuntu-latest
steps:
- name: Set variables
id: variables
run: |
PROJECT="edgecraft-designer"
VERSION="${{ github.event.inputs.version }}"
REGISTRY="ghcr.io/${{ github.repository_owner }}"
if [[ $VERSION == "" ]]; then
GITHUB_REF="${{ github.ref }}"
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
elif [[ $GITHUB_REF == refs/heads/* ]]; then
VERSION="$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')-$(date '+%Y%m%d')"
elif [[ $GITHUB_REF == refs/pull/* ]]; then
VERSION="pr-${{ github.event.number }}"
fi
fi
echo ::set-output name=prefix::${REGISTRY}
echo ::set-output name=version::${VERSION}
echo ::set-output name=project::${PROJECT}
- name: Check out the repository
uses: actions/checkout@v2
# - name: Login GHCR
# uses: docker/login-action@v1
# with:
# registry: ghcr.io
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}
# - name: Build docker image [${{steps.variables.outputs.project}}]
# uses: docker/build-push-action@v2
# with:
# context: .
# file: ./Dockerfile
# push: true
# tags: |
# ${{steps.variables.outputs.prefix}}/${{steps.variables.outputs.project}}:${{steps.variables.outputs.version}}
# ${{steps.variables.outputs.prefix}}/${{steps.variables.outputs.project}}:latest
# release
- name: Release
uses: actions/create-release@v1
id: create_release
with:
draft: false
prerelease: true
release_name: Release ${{ steps.variables.outputs.version }}
tag_name: ${{ steps.variables.outputs.version }}
env:
GITHUB_TOKEN: ${{ github.token }}