Code Issues Pull Requests Actions Packages Projects Releases 15 Wiki Activity Security Code Quality
4 Commits
3 changed files with 77 additions and 26 deletions

No files matched your search

+51
View File
@@ -0,0 +1,51 @@
name: Load runner environment
description: Copy named variables from the runner process into the job env context.
inputs:
names:
description: Space-separated variable names, loaded in the given order.
required: true
required:
description: Fail when a named variable is missing or empty.
required: false
default: "true"
runs:
using: composite
steps:
- name: Load runner environment
shell: bash
env:
LOAD_ENV_NAMES: ${{ inputs.names }}
LOAD_ENV_REQUIRED: ${{ inputs.required }}
run: |
set -euo pipefail
if [[ -z "${LOAD_ENV_NAMES// }" ]]; then
echo "No environment variable names were given"
exit 1
fi
for name in $LOAD_ENV_NAMES; do
if [[ ! "$name" =~ ^[A-Za-z_][A-Za-z0-9_]*$ ]]; then
echo "Invalid environment variable name: ${name}"
exit 1
fi
value="${!name-}"
if [[ -z "$value" ]]; then
if [[ "${LOAD_ENV_REQUIRED}" == "true" ]]; then
echo "${name} is not set on this runner"
exit 1
fi
echo "Skipping unset ${name}"
continue
fi
if [[ "$value" != *$'\n'* ]]; then
echo "::add-mask::${value}"
fi
delimiter="LOAD_ENV_${name}_${RANDOM}_$$"
{
printf '%s<<%s\n' "$name" "$delimiter"
printf '%s\n' "$value"
printf '%s\n' "$delimiter"
} >> "$GITHUB_ENV"
echo "Loaded ${name} from the runner"
done
+23 -16
View File
@@ -3,7 +3,7 @@ name: Release
on:
push:
tags:
- "**"
- "v*.*.*"
permissions:
contents: write
@@ -23,39 +23,45 @@ jobs:
with:
fetch-depth: 0
# Public source. A repo without its own cliff.toml downloads this file.
- name: Use shared cliff.toml when the repo has none
# Local config wins, in this order. Download the shared file only when none exist.
- name: Resolve cliff.toml
id: cliff-config
env:
CLIFF_REPO: ${{ vars.CLIFF_CONFIG_REPO || 'gitea/global-workflow' }}
CLIFF_CONFIGS: cliff.toml .github/cliff.toml .gitea/cliff.toml
run: |
set -euo pipefail
if [[ -f cliff.toml ]]; then
echo "Using cliff.toml from this repository"
for candidate in $CLIFF_CONFIGS; do
if [[ -f "$candidate" ]]; then
echo "Using ${candidate} from this repository"
echo "config=${candidate}" >> "$GITHUB_OUTPUT"
exit 0
fi
done
url="${GITHUB_API_URL}/repos/${CLIFF_REPO}/raw/cliff.toml?ref=main"
echo "No cliff.toml in this repository; fetching ${url}"
echo "No local cliff.toml; fetching ${url}"
curl --silent --show-error --fail --location --output cliff.toml "$url"
echo "config=cliff.toml" >> "$GITHUB_OUTPUT"
- name: Read GITHUB_TOKEN from the runner
uses: https://git.sothink.vn/gitea/global-workflow/.gitea/actions/load-env@main
with:
names: GITHUB_TOKEN
# Gitea's GITHUB_TOKEN is rejected by api.github.com. Pass a github.com PAT instead.
- name: Generate release notes
uses: orhun/git-cliff-action@v4
with:
config: cliff.toml
config: ${{ steps.cliff-config.outputs.config }}
args: --latest --strip header
github_token: ${{ env.GITHUB_TOKEN }}
env:
OUTPUT: release-notes.md
- name: Read Release Token from the runner
run: |
if [[ -z "${RELEASE_TOKEN:-}" ]]; then
exit 1
fi
{
echo "RELEASE_TOKEN<<__RELEASE_TOKEN__"
printf '%s\n' "$RELEASE_TOKEN"
echo "__RELEASE_TOKEN__"
} >> "$GITHUB_ENV"
uses: https://git.sothink.vn/gitea/global-workflow/.gitea/actions/load-env@main
with:
names: RELEASE_TOKEN
- name: Create release
uses: softprops/action-gh-release@v3
@@ -64,3 +70,4 @@ jobs:
prerelease: ${{ contains(github.ref, '-alpha') || contains(github.ref, '-beta') || contains(github.ref, '-rc') }}
body_path: release-notes.md
token: ${{ env.RELEASE_TOKEN }} # Use this token if you want user author is 'github-actions' bot
draft: false
@@ -22,16 +22,9 @@ jobs:
upload-artifact: false
- name: Read API key from the runner
run: |
if [[ -z "${DT_API_KEY:-}" ]]; then
echo "DT_API_KEY is not set on this runner"
exit 1
fi
{
echo "DT_API_KEY<<__DT_API_KEY__"
printf '%s\n' "$DT_API_KEY"
echo "__DT_API_KEY__"
} >> "$GITHUB_ENV"
uses: https://git.sothink.vn/gitea/global-workflow/.gitea/actions/load-env@main
with:
names: DT_API_KEY
- name: Upload SBOM to Dependency-Track
uses: DependencyTrack/gh-upload-sbom@v4