mirror of
https://github.com/yeasy/docker_practice.git
synced 2026-08-10 08:27:25 +00:00
ci: sanitize auto-release artifact tag names
This commit is contained in:
@@ -48,20 +48,24 @@ jobs:
|
||||
id: tag
|
||||
run: |
|
||||
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
|
||||
echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
|
||||
tag_name="${GITHUB_REF#refs/tags/}"
|
||||
else
|
||||
echo "TAG_NAME=latest" >> "$GITHUB_OUTPUT"
|
||||
tag_name="latest"
|
||||
fi
|
||||
safe_tag_name=$(printf '%s' "$tag_name" | sed 's/[^A-Za-z0-9._-]/-/g')
|
||||
safe_tag_name="${safe_tag_name:-latest}"
|
||||
echo "TAG_NAME=${tag_name}" >> "$GITHUB_OUTPUT"
|
||||
echo "SAFE_TAG_NAME=${safe_tag_name}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Build PDF
|
||||
run: mdpress build --format pdf --output docker_practice-${{ steps.tag.outputs.TAG_NAME || 'latest' }}.pdf
|
||||
run: mdpress build --format pdf --output docker_practice-${{ steps.tag.outputs.SAFE_TAG_NAME || 'latest' }}.pdf
|
||||
|
||||
- name: Create Release with PDF
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
uses: softprops/action-gh-release@v3
|
||||
with:
|
||||
generate_release_notes: true
|
||||
files: docker_practice-${{ steps.tag.outputs.TAG_NAME }}.pdf
|
||||
files: docker_practice-${{ steps.tag.outputs.SAFE_TAG_NAME }}.pdf
|
||||
|
||||
- name: Upload PDF as artifact
|
||||
uses: actions/upload-artifact@v7
|
||||
@@ -80,7 +84,7 @@ jobs:
|
||||
sudo dpkg -i /tmp/pandoc.deb && pandoc --version | head -1
|
||||
PUPPETEER_SKIP_DOWNLOAD=true npm install -g @mermaid-js/mermaid-cli@10
|
||||
TITLE=$(python3 -c "import json,os;print((json.load(open('book.json')).get('title') if os.path.exists('book.json') else '') or '${{ github.event.repository.name }}')")
|
||||
TAG=$(echo "${{ steps.tag.outputs.TAG_NAME || 'latest' }}" | sed 's#.*/##') # slash-free (handles non-tag dispatch)
|
||||
TAG="${{ steps.tag.outputs.SAFE_TAG_NAME || 'latest' }}"
|
||||
python3 tools/render_mermaid.py --book-dir . --svg-out /tmp/mmsvg
|
||||
python3 tools/build_html_reader.py --book-dir . --title "$TITLE" --svg-dir /tmp/mmsvg \
|
||||
--out "${{ github.event.repository.name }}-${TAG}.html"
|
||||
@@ -91,7 +95,7 @@ jobs:
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: ${{ steps.tag.outputs.TAG_NAME }}
|
||||
files: "${{ github.event.repository.name }}-${{ steps.tag.outputs.TAG_NAME }}.html"
|
||||
files: "${{ github.event.repository.name }}-${{ steps.tag.outputs.SAFE_TAG_NAME }}.html"
|
||||
|
||||
- name: Upload HTML as artifact
|
||||
if: steps.htmlreader.outcome == 'success'
|
||||
|
||||
Reference in New Issue
Block a user