In order to refactor this notification between alls projetcs, we chooseto use a custom github action
74 lines
1.9 KiB
YAML
74 lines
1.9 KiB
YAML
name: Docker Hub Workflow
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
push:
|
|
branches:
|
|
- 'main'
|
|
tags:
|
|
- 'v*'
|
|
pull_request:
|
|
branches:
|
|
- 'main'
|
|
|
|
jobs:
|
|
build-and-push:
|
|
runs-on: ubuntu-latest
|
|
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: "oidc2fer,secrets"
|
|
-
|
|
name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
submodules: recursive
|
|
token: ${{ steps.app-token.outputs.token }}
|
|
-
|
|
name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
-
|
|
name: Docker meta
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: lasuite/oidc2fer
|
|
-
|
|
name: Load sops secrets
|
|
uses: rouja/actions-sops@main
|
|
with:
|
|
secret-file: secrets/numerique-gouv/oidc2fer/secrets.enc.env
|
|
age-key: ${{ secrets.SOPS_PRIVATE }}
|
|
-
|
|
name: Login to DockerHub
|
|
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: .
|
|
target: production
|
|
platforms: linux/amd64,linux/arm64
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
|
|
notify-argocd:
|
|
runs-on: ubuntu-latest
|
|
if: |
|
|
github.event_name != 'pull_request'
|
|
needs:
|
|
- build-and-push
|
|
steps:
|
|
- uses: numerique-gouv/action-argocd-webhook-notification@main
|
|
id: notify
|
|
with:
|
|
deployment_repo_path: "${{ github.repository }}"
|
|
argocd_webhook_secret: "${{ secrets.ARGOCD_PREPROD_WEBHOOK_SECRET }}"
|
|
argocd_url: "${{ vars.ARGOCD_PREPROD_WEBHOOK_URL }}"
|