Code Issues Pull Requests Actions Packages Projects Releases 15 Wiki Activity Security Code Quality

ci: Refactor release and scan-vulnerabilities workflows to utilize shared environment loading action for improved security and clarity

This commit is contained in:
tienbh committed 2026-11-25 14:30:09 +07:00 Verified
1 parent b4bdde9180
commit 5cc756db7a
2 files changed
+24 -25

No files matched your search

+21 -15
View File
@@ -23,39 +23,45 @@ jobs:
with: with:
fetch-depth: 0 fetch-depth: 0
# Public source. A repo without its own cliff.toml downloads this file. # Local config wins, in this order. Download the shared file only when none exist.
- name: Use shared cliff.toml when the repo has none - name: Resolve cliff.toml
id: cliff-config
env: env:
CLIFF_REPO: ${{ vars.CLIFF_CONFIG_REPO || 'gitea/global-workflow' }} CLIFF_REPO: ${{ vars.CLIFF_CONFIG_REPO || 'gitea/global-workflow' }}
CLIFF_CONFIGS: cliff.toml .github/cliff.toml .gitea/cliff.toml
run: | run: |
set -euo pipefail set -euo pipefail
if [[ -f cliff.toml ]]; then for candidate in $CLIFF_CONFIGS; do
echo "Using cliff.toml from this repository" if [[ -f "$candidate" ]]; then
echo "Using ${candidate} from this repository"
echo "config=${candidate}" >> "$GITHUB_OUTPUT"
exit 0 exit 0
fi fi
done
url="${GITHUB_API_URL}/repos/${CLIFF_REPO}/raw/cliff.toml?ref=main" 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" 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. # Gitea's GITHUB_TOKEN is rejected by api.github.com. Pass a github.com PAT instead.
- name: Generate release notes - name: Generate release notes
uses: orhun/git-cliff-action@v4 uses: orhun/git-cliff-action@v4
with: with:
config: cliff.toml config: ${{ steps.cliff-config.outputs.config }}
args: --latest --strip header args: --latest --strip header
github_token: ${{ env.GITHUB_TOKEN }}
env: env:
OUTPUT: release-notes.md OUTPUT: release-notes.md
- name: Read Release Token from the runner - name: Read Release Token from the runner
run: | uses: https://git.sothink.vn/gitea/global-workflow/.gitea/actions/load-env@main
if [[ -z "${RELEASE_TOKEN:-}" ]]; then with:
exit 1 names: RELEASE_TOKEN
fi
{
echo "RELEASE_TOKEN<<__RELEASE_TOKEN__"
printf '%s\n' "$RELEASE_TOKEN"
echo "__RELEASE_TOKEN__"
} >> "$GITHUB_ENV"
- name: Create release - name: Create release
uses: softprops/action-gh-release@v3 uses: softprops/action-gh-release@v3
@@ -22,16 +22,9 @@ jobs:
upload-artifact: false upload-artifact: false
- name: Read API key from the runner - name: Read API key from the runner
run: | uses: https://git.sothink.vn/gitea/global-workflow/.gitea/actions/load-env@main
if [[ -z "${DT_API_KEY:-}" ]]; then with:
echo "DT_API_KEY is not set on this runner" names: DT_API_KEY
exit 1
fi
{
echo "DT_API_KEY<<__DT_API_KEY__"
printf '%s\n' "$DT_API_KEY"
echo "__DT_API_KEY__"
} >> "$GITHUB_ENV"
- name: Upload SBOM to Dependency-Track - name: Upload SBOM to Dependency-Track
uses: DependencyTrack/gh-upload-sbom@v4 uses: DependencyTrack/gh-upload-sbom@v4