Files
blog/.gitea/workflows/publish-blog.yml
T

97 lines
3.4 KiB
YAML

name: Publish blog immutable package
# Every main push builds and tests the release. Publication additionally needs
# the activation variable, the reviewed repository gate and the scoped package
# secrets; without them nothing is published. Publication never deploys:
# selecting the release is a reviewed change to gitops-sandbox/stacks.yml.
on:
push:
branches: [main]
workflow_dispatch:
inputs:
revision:
description: Full public/blog commit to publish
required: true
permissions:
contents: read
concurrency:
group: blog-publish
cancel-in-progress: false
jobs:
validate:
runs-on: ubuntu-latest
container:
image: git.librete.ch/public/runner-image:v0.2.0@sha256:f60c587d3c0b0aac04a572db5349e27672bf76baec2ce547a3dcc28cebcf1b7e
timeout-minutes: 15
env:
REQUESTED_REVISION: ${{ inputs.revision || github.sha }}
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
with:
ref: ${{ inputs.revision || github.sha }}
fetch-depth: 0
submodules: true
- name: Validate requested source, tests and build
run: |
set -eu
test "$(git rev-parse HEAD)" = "$REQUESTED_REVISION"
(cd delivery && python3 -m unittest discover -s tests -v)
delivery/build.sh
publish:
needs: validate
if: ${{ vars.BLOG_PACKAGE_PUBLISH_ENABLED == 'true' }}
runs-on: ubuntu-latest
container:
image: git.librete.ch/public/runner-image:v0.2.0@sha256:f60c587d3c0b0aac04a572db5349e27672bf76baec2ce547a3dcc28cebcf1b7e
timeout-minutes: 15
env:
ACTIVATION: ${{ vars.BLOG_PACKAGE_PUBLISH_ENABLED }}
REQUESTED_REVISION: ${{ inputs.revision || github.sha }}
STATIC_PACKAGE_USER: ${{ secrets.BLOG_PACKAGE_USER }}
STATIC_PACKAGE_TOKEN: ${{ secrets.BLOG_PACKAGE_TOKEN }}
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
with:
ref: ${{ inputs.revision || github.sha }}
fetch-depth: 0
submodules: true
- name: Enforce reviewed publication gate
run: |
set -eu
test "$ACTIVATION" = true
python3 delivery/scripts/delivery_gate.py package_publish \
--config delivery/.delivery/config.json
test -n "$STATIC_PACKAGE_USER"
test -n "$STATIC_PACKAGE_TOKEN"
- name: Build and publish immutable package files
run: |
set -eu
test "$(git rev-parse HEAD)" = "$REQUESTED_REVISION"
delivery/build.sh
python3 delivery/scripts/generic_package.py \
--registry "${{ gitea.server_url }}" \
--owner public \
--package blog-site \
--revision "$REQUESTED_REVISION" \
--archive delivery/.build/site.tar.gz \
--checksum delivery/.build/site.tar.gz.sha256 \
--coordinate delivery/.build/release-coordinate.json \
> delivery/.build/published.json
cat delivery/.build/published.json
echo "Select this release with a reviewed gitops-sandbox stacks.yml change:"
python3 - delivery/.build/published.json <<'PY'
import json, sys
c = json.load(open(sys.argv[1]))
print(" blog:")
for key in ("revision", "artifact_url", "artifact_digest"):
print(f" {key}: {c[key]}")
PY