# Build every rpms/* package missing from its artifactapi rpm-vendor-* repo, per distro; push to main uploads them. name: publish on: pull_request: push: branches: [main] permissions: {} concurrency: group: publish-${{ github.ref }} cancel-in-progress: ${{ github.event_name == 'pull_request' }} env: VAULT_ADDR: https://vault.service.consul:8200 ARTIFACTAPI: https://artifactapi.k8s.syd1.au.unkin.net IMAGE: artifactapi.k8s.syd1.au.unkin.net/docker-internal/rpmbuilder:0.1.0-alma9 jobs: build: if: ${{ github.event_name != 'push' }} runs-on: iuclabs-build permissions: contents: read strategy: fail-fast: false matrix: &distros include: - { distro: almalinux/el9, repo: rpm-vendor-el9 } - { distro: fedora/42, repo: rpm-vendor-f42 } - { distro: fedora/43, repo: rpm-vendor-f43 } - { distro: fedora/44, repo: rpm-vendor-f44 } steps: - &checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - &build name: build rpms env: DISTRO: ${{ matrix.distro }} run: | docker run --rm --privileged -v "${GITHUB_WORKSPACE}:/src" -w /src "${IMAGE}" \ ./tools/build build-all --distro "${DISTRO}" --buildah find . -type f -name '*.rpm' publish: if: ${{ github.event_name == 'push' }} runs-on: iuclabs-build permissions: contents: read id-token: write strategy: fail-fast: false matrix: *distros steps: - *checkout - *build # login after the build: vault tokens live 15m - uses: hashicorp/vault-action@892a26828f195e65540a40b4768ae4571f51ebfc # v4.0.0 with: url: ${{ env.VAULT_ADDR }} method: jwt path: jwt/github/iuclabs role: rpmbuilder_publish jwtGithubAudience: ${{ env.VAULT_ADDR }} secrets: | identity/oidc/token/artifactapi-writer token | ARTIFACTAPI_TOKEN - name: upload rpms env: REPO: ${{ matrix.repo }} run: | set -euo pipefail auth="${RUNNER_TEMP}/auth" printf 'Authorization: Bearer %s\n' "${ARTIFACTAPI_TOKEN}" > "${auth}" find . -type f -name '*.rpm' -print0 | while IFS= read -r -d '' rpm; do file=$(basename "${rpm}") # artifactapi has no HEAD route (405); probe the served Packages path. code=$(curl -s --cacert /etc/vault-ca/ca.crt -o /dev/null -w '%{http_code}' "${ARTIFACTAPI}/api/v2/remotes/${REPO}/files/Packages/${file}" || true) if [ "${code}" = 200 ]; then echo "${file} already exists in ${REPO}; skipping" continue fi curl -fsS --cacert /etc/vault-ca/ca.crt -X PUT "${ARTIFACTAPI}/api/v2/remotes/${REPO}/files/${file}" \ -H "Content-Type: application/x-rpm" -H @"${auth}" --data-binary @"${rpm}" done