Skip to content

Refactoring course (#178) #40

Refactoring course (#178)

Refactoring course (#178) #40

Workflow file for this run

# 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