GHA: Docker build: Use GITHUB token to log in to the container registry #1267
Workflow file for this run
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: Build docker container for the SP Dashboard | |
on: | |
pull_request: | |
release: | |
types: [ published ] | |
push: | |
branches: [ develop ] | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-20.04 | |
permissions: | |
packages: write | |
contents: read | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 14 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
with: | |
driver-opts: | | |
image=moby/buildkit:v0.12.0 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set docker metadata for php fpm container | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
ghcr.io/surfnet/sp-dashboard | |
tags: | | |
type=schedule | |
type=ref,event=branch | |
type=ref,event=pr | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{major}} | |
type=sha | |
- name: Build the php-fpm container and push to GitHub Packages | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: docker/Dockerfile | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
target: phpfpm-build | |
- name: Build the Apache container and push to GitHub Packages | |
uses: docker/build-push-action@v1 | |
with: | |
dockerfile: docker/Dockerfile | |
registry: ghcr.io | |
repository: surfnet/sp-dashboard/spdashboard_web | |
tag_with_ref: true | |
push: true | |
target: httpd-build |