Merge pull request #267 from keymanapp/fix/unpin-sha #12
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Docker-build | |
on: | |
push: | |
branches: [ "master", "staging" ] | |
paths: | |
- .github/** | |
- composer.* | |
- resources/** | |
- "*Dockerfile" | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: keymanapp/api-keyman-com | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
# Workaround: https://github.com/docker/build-push-action/issues/461 | |
- name: Setup Docker buildx | |
uses: docker/setup-buildx-action@v2 | |
# Login against a Docker registry except on PR | |
- name: Log into registry ${{ env.REGISTRY }} | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
# Extract metadata (tags, labels) for PHP container | |
- name: Extract Docker metadata for PHP runtime | |
id: meta-app | |
uses: docker/metadata-action@v4 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-app | |
tags: | | |
type=raw,value={{branch}} | |
type=raw,value=latest | |
labels: | | |
org.opencontainers.image.description=PHP api runtime | |
# Extract metadata (tags, labels) for sqlserver container | |
- name: Extract Docker metadata for SQLServer container | |
id: meta-db | |
uses: docker/metadata-action@v4 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-db | |
tags: | | |
type=raw,value={{branch}} | |
type=raw,value=latest | |
labels: | | |
org.opencontainers.image.description=SQLServer | |
# Build and push Docker image with Buildx (don't push on PR) | |
- name: Build and push Docker image for PHP runtime | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta-app.outputs.tags }} | |
labels: ${{ steps.meta-app.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
# Build and push Docker image with Buildx (don't push on PR) | |
- name: Build and push Docker image for SQLServer containe | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: mssql.Dockerfile | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta-db.outputs.tags }} | |
labels: ${{ steps.meta-db.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max |