Skip to content

obfuscate additional config vars (#17) #43

obfuscate additional config vars (#17)

obfuscate additional config vars (#17) #43

Workflow file for this run

name: wipac ci/cd
on:
push:
branches:
- '**'
tags-ignore:
- '**'
env:
py_version: '3.13'
REGISTRY_IMAGE: ghcr.io/wipacrepo/scitoken-issuer
jobs:
flake8:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.sha }} # lock to triggered commit (github.ref is dynamic)
- uses: astral-sh/ruff-action@v3
py-versions:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.versions.outputs.matrix }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.sha }} # lock to triggered commit (github.ref is dynamic)
- id: versions
uses: WIPACrepo/wipac-dev-py-versions-action@v2.5
mypy:
needs: [ py-versions ]
runs-on: ubuntu-latest
strategy:
max-parallel: 4
fail-fast: false
matrix:
py3: ${{ fromJSON(needs.py-versions.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.sha }} # lock to triggered commit (github.ref is dynamic)
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.py3 }}
- uses: WIPACrepo/wipac-dev-mypy-action@v2.0
tests:
needs: [py-versions]
runs-on: ubuntu-latest
strategy:
max-parallel: 4
fail-fast: false
matrix:
version: ${{ fromJSON(needs.py-versions.outputs.matrix) }}
services:
keycloak:
image: ghcr.io/wipacrepo/keycloak-rest-services:test-keycloak-master
env:
KEYCLOAK_ADMIN: admin
KEYCLOAK_ADMIN_PASSWORD: admin
CMD: start-dev
ports:
- 8080:8080
mongo:
image: mongo:8
ports:
- 27017:27017
env:
CI_TESTING: "true"
IDP_ADDRESS: http://localhost:8080
USERNAME: admin
PASSWORD: admin
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.sha }} # lock to triggered commit (github.ref is dynamic)
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.version }}
- run: |
pip install --upgrade pip wheel setuptools
pip install -e .[tests]
pytest -v --log-level debug --tb=short
docker-build:
name: "Docker Image"
runs-on: ubuntu-latest
steps:
# Note: we need to checkout the repository at the workflow sha in case during the workflow
# the branch was updated. To keep PSR working with the configured release branches,
# we force a checkout of the desired release branch but at the workflow sha HEAD.
- name: Setup | Checkout Repository at workflow sha
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.sha }}
- name: Build Docker Image
uses: docker/build-push-action@v4
with:
context: .
push: false
release:
if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }}
needs: [flake8, tests, docker-build]
runs-on: ubuntu-latest
concurrency: release
permissions:
id-token: write
contents: write
outputs:
released: ${{ steps.release.outputs.released }}
tag: ${{ steps.release.outputs.tag }}
steps:
# Note: we need to checkout the repository at the workflow sha in case during the workflow
# the branch was updated. To keep PSR working with the configured release branches,
# we force a checkout of the desired release branch but at the workflow sha HEAD.
- name: Setup | Checkout Repository at workflow sha
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.sha }}
- name: Setup | Force correct release branch on workflow sha
run: |
git checkout -B ${{ github.ref_name }} ${{ github.sha }}
- name: Action | Semantic Version Release
id: release
# Adjust tag with desired version if applicable.
uses: python-semantic-release/python-semantic-release@v9.8.1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
git_committer_name: "github-actions"
git_committer_email: "actions@users.noreply.github.com"
- name: Publish | Upload to GitHub Release Assets
uses: python-semantic-release/publish-action@v9.16.1
if: steps.release.outputs.released == 'true'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ steps.release.outputs.tag }}
docker_release:
if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' && needs.release.outputs.released == 'true' }}
needs: [release]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
- linux/arm64
permissions:
packages: write
steps:
# Note: we checkout the just created tag here
- name: Setup | Checkout Repository at tag
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ needs.release.outputs.tag }}
- name: Prepare
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Push Docker Image
id: build
uses: docker/build-push-action@v6
with:
context: .
platforms: ${{ matrix.platform }}
build-args: |
SETUPTOOLS_SCM_PRETEND_VERSION=${{ needs.release.outputs.tag }}
tags: ${{ env.REGISTRY_IMAGE }}
labels: ${{ steps.docker_meta.outputs.labels }}
outputs: type=image,push-by-digest=true,name-canonical=true,push=true
- name: Export digest
run: |
mkdir -p ${{ runner.temp }}/digests
digest="${{ steps.build.outputs.digest }}"
touch "${{ runner.temp }}/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ env.PLATFORM_PAIR }}
path: ${{ runner.temp }}/digests/*
if-no-files-found: error
retention-days: 1
docker_merge:
if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' && needs.release.outputs.released == 'true' }}
needs: [release, docker_release]
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
path: ${{ runner.temp }}/digests
pattern: digests-*
merge-multiple: true
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.REGISTRY_IMAGE }}
tags: |
type=semver,pattern={{major}},value=${{ needs.release.outputs.tag }}
type=semver,pattern={{major}}.{{minor}},value=${{ needs.release.outputs.tag }}
type=semver,pattern={{major}}.{{minor}}.{{patch}},value=${{ needs.release.outputs.tag }}
- name: Create manifest list and push
working-directory: ${{ runner.temp }}/digests
run: |
docker buildx imagetools create \
$(echo $DOCKER_METADATA_OUTPUT_JSON | jq -cr '.tags | map("-t " + .) | join(" ")') \
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
# $(echo $DOCKER_METADATA_OUTPUT_JSON | jq -r '.annotations | map("--annotation \"" + . + "\"") | join(" ")')