-
Notifications
You must be signed in to change notification settings - Fork 15
59 lines (48 loc) · 1.46 KB
/
pkg.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
# Continuous Delivery (Packaging) pipeline
name: PKG
on:
push:
branches: [ "master" ]
tags: [ '*' ]
workflow_dispatch: {}
env:
app_image: hobbyfarm/admin-ui
should_push_image: |-
${{
github.event_name == 'push' && (
github.ref_type == 'tag' ||
github.ref_name == 'master'
)
}}
should_tag_latest: |-
${{
github.event_name == 'push' &&
github.ref_type == 'tag'
}}
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@master
- name: Create container image
run: |
docker build -f Dockerfile -t $app_image:${GIT_COMMIT_SHORT_HASH:-dev} .
- name: Login container registry
if: fromJSON(env.should_push_image)
run: |
echo "${{ secrets.REGISTRY_PASSWORD }}" \
| docker login -u "${{ secrets.REGISTRY_USER }}" --password-stdin
- name: Push container image to registry
if: fromJSON(env.should_push_image)
run: |
safe_ref=$(echo "${{ github.ref_name }}" | sed -e 's/[^a-zA-Z0-9\-\.]/-/g')
publish_tag=$app_image:$safe_ref
docker tag $app_image:${GIT_COMMIT_SHORT_HASH:-dev} $publish_tag
docker push $publish_tag
- name: Push latest tag
if: fromJSON(env.should_tag_latest)
run: |
docker tag $app_image:${GIT_COMMIT_SHORT_HASH:-dev} $app_image:latest
docker push $app_image:latest