Skip to content

Add publish of build container #33

Add publish of build container

Add publish of build container #33

Workflow file for this run

name: Container CI
on:
push:
# Build for main, tags and PRs
# Builds from PRs are not pushed to the registry because of rules in the steps
branches:
# push these changes to the branch 'docker' for container publishing
- fastcs-dev
tags:
- "*"
pull_request:
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0 # All history
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Log in to GitHub Docker Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=ref,event=branch
type=ref,event=tag
type=raw,value=latest
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Docker meta config developer
id: meta-developer
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.repository }}-developer
tags: |
type=ref,event=branch
type=ref,event=tag
type=raw,value=latest
- name: Docker build developer image
uses: docker/build-push-action@v4
with:
context: .
file: Dockerfile
target: developer
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta-build.outputs.tags }}
labels: ${{ steps.meta-build.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
- name: Docker meta config build
id: meta-build
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.repository }}-build
tags: |
type=ref,event=branch
type=ref,event=tag
type=raw,value=latest
- name: Docker build build image
uses: docker/build-push-action@v4
with:
context: .
file: Dockerfile
target: build
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta-build.outputs.tags }}
labels: ${{ steps.meta-build.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
- name: Docker meta config runtime
id: meta-runtime
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.repository }}-runtime
tags: |
type=ref,event=branch
type=ref,event=tag
type=raw,value=latest
- name: Docker build runtime image
uses: docker/build-push-action@v4
with:
context: .
file: Dockerfile
target: runtime
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta-runtime.outputs.tags }}
labels: ${{ steps.meta-runtime.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache