name: Docker image build on: push: branches: [ "main" ] # Publish semver tags as releases. paths: - '**.php' - './composer.*' - './config/**' - './.github/**' - 'Procfile' - 'project.toml' 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@v1.0.1 - 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/buildpacks:20 \ --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