Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GHA: Docker build: Use GITHUB token to log in to the container registry #615

Merged
merged 2 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 65 additions & 29 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,72 @@ on:

jobs:
build:

runs-on: ubuntu-20.04
permissions:
packages: write
contents: read

steps:

- name: Check out the repo
uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version: 14
- name: Build the php-fpm container and push to GitHub Packages
uses: docker/build-push-action@v1
with:
dockerfile: docker/Dockerfile
username: ${{ github.actor }}
password: ${{ secrets.GH_CONTAINER_REGISTRY_PAT }}
registry: ghcr.io
repository: surfnet/sp-dashboard/spdashboard_php-fpm
tag_with_ref: true
push: true
target: phpfpm-build

- name: Build the Apache container and push to GitHub Packages
uses: docker/build-push-action@v1
with:
dockerfile: docker/Dockerfile
username: ${{ github.actor }}
password: ${{ secrets.GH_CONTAINER_REGISTRY_PAT }}
registry: ghcr.io
repository: surfnet/sp-dashboard/spdashboard_web
tag_with_ref: true
push: true
target: httpd-build
- 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@v3

- 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: metaphpfpm
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/surfnet/sp-dashboard/spdashboard_php-fpm
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}

- name: Set docker metadata for web container
id: metahttpd
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/surfnet/sp-dashboard/spdashboard_web
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}

- 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.metaphpfpm.outputs.tags }}
target: phpfpm-build

- name: Build the Apache container and push to GitHub Packages
uses: docker/build-push-action@v4
with:
context: .
file: docker/Dockerfile
push: true
tags: ${{ steps.metahttpd.outputs.tags }}
target: httpd-build
4 changes: 3 additions & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ RUN yarn install && \

FROM ghcr.io/openconext/openconext-containers/openconext-httpd:latest AS httpd-build
LABEL maintainer Bart Geesink (bart.geesink@surf.nl)
LABEL org.opencontainers.image.source=https://github.com/surfnet/sp-dashboard
RUN mkdir -p /var/www/html/
COPY --from=node-build /var/www/html/public/. /var/www/html/public/
COPY --from=js-build /var/www/html/public/build/. /var/www/html/public/build/
Expand All @@ -37,7 +38,8 @@ COPY --from=node-build /var/www/html/composer.json /var/www/html/
COPY --from=js-build /var/www/html/public/build/. /var/www/html/public/build/
COPY --from=js-build /var/www/html/node_modules/. /var/www/html/node_modules/

LABEL maintainer "Bart Geesink" <bart.geesink@surf.nl>
LABEL maintainer Bart Geesink (bart.geesink@surf.nl)
LABEL org.opencontainers.image.source=https://github.com/surfnet/sp-dashboard

RUN mkdir -p /var/www/html/var/cache && \
mkdir -p /var/www/html/var/log && \
Expand Down
Loading