Create docker-publish.yml

This commit is contained in:
Gabor FELEGYHAZI
2022-06-28 09:29:52 +02:00
committed by GitHub
parent e68f6ff23d
commit 360d839283

52
.github/workflows/docker-publish.yml vendored Normal file
View File

@@ -0,0 +1,52 @@
name: Docker image build
on:
push:
branches: [ "main" ]
# Publish semver tags as releases.
tags: [ 'v*.*.*' ]
paths:
- '**.php'
- './composer.*'
- './config/*'
- './.github/*'
pull_request:
branches: [ "main" ]
env:
COMPOSER_AUTH: "{ \"github-oauth\": {\"github.com\": \"${{ secrets.HVG_DEV_GH_TOKEN }}\"}}"
jobs:
pack-example:
name: Pack example!
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: andrioid/setup-pack@latest
- name: Docker registry login
uses: docker/login-action@v1
with:
registry: ghcr.io/hvg
username: hvg-dev
password: ${{ secrets.HVG_DEV_GH_TOKEN }}
- name: Set build environment
run: |
year=$(date +%Y);
month=$(date +%m);
ref="${GITHUB_REF#refs/*/}";
echo "REF=$ref" >> $GITHUB_ENV;
tag="${GITHUB_REF#tags/*/}";
[[ $tag == '' ]] || tag="${year}.${month}.${{ github.run_number }}";
echo "TAG=$tag" >> $GITHUB_ENV;
- name: Build Image with pack
run: |
pack build ghcr.io/hvg/blog:$TAG \
--builder heroku/builder-classic:22 \
--descriptor project.toml \
--workspace /app \
--env COMPOSER_AUTH=$COMPOSER_AUTH;
- name: Tag Docker image to ref
run: |
docker tag ghcr.io/hvg/blog:$TAG ghcr.io/hvg/blog:$REF