Skip to content

[LT] Add ci

[LT] Add ci #90

Workflow file for this run

name: Docker Hub Workflow
on:
workflow_dispatch:
push:
branches:
- 'main'
tags:
- 'v*'
pull_request:
branches:
- 'main'
env:
DOCKER_USER: 1001:127
jobs:
build-and-push-backend:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- dockerfile: dockerfiles/goofys/Dockerfile
image: lasuite/goofys
path: dockerfiles/goofys
cmd_version: "echo \"VERSION=$( awk '/VERSION/ {print substr($3, 2)}' dockerfiles/goofys/Dockerfile)\" >> $GITHUB_ENV"
- dockerfile: dockerfiles/keycloak-apps/Dockerfile
image: lasuite/keycloak-apps
path: dockerfiles/keycloak-apps
cmd_version: "echo \"$(cat dockerfiles/keycloak-apps/Dockerfile | head -n1 | cut -d' ' -f2)\" >> $GITHUB_ENV"
- dockerfile: dockerfiles/grist/Dockerfile
image: lasuite/grist
path: dockerfiles/grist
cmd_version: "grep -Po \"GRIST_\\KVERSION=.*\" dockerfiles/grist/Dockerfile | head -n 1 >> $GITHUB_ENV"
steps:
-
uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
repositories: "dockerfiles,secrets"
-
name: Checkout repository
uses: actions/checkout@v2
with:
submodules: recursive
token: ${{ steps.app-token.outputs.token }}
-
name: Read version
run: ${{ matrix.cmd_version }}
-
name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ matrix.image }}
tags: |
type=raw,value=${{ env.VERSION }}
-
name: Load sops secrets
uses: rouja/actions-sops@main
with:
secret-file: secrets/numerique-gouv/dockerfiles/secrets.enc.env
age-key: ${{ secrets.SOPS_PRIVATE }}
-
name: Login to DockerHub
if: github.event_name != 'pull_request'
run: echo "$DOCKER_HUB_PASSWORD" | docker login -u "$DOCKER_HUB_USER" --password-stdin
-
name: Build and push
uses: docker/build-push-action@v5
with:
context: ${{ matrix.path }}
file: ${{ matrix.dockerfile }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}