Skip to content

Add .NET setup step & fix build image name (#63) #110

Add .NET setup step & fix build image name (#63)

Add .NET setup step & fix build image name (#63) #110

Workflow file for this run

name: Generate action documentation
on:
push:
branches: [trunk]
pull_request:
branches: [trunk]
jobs:
set-env:
name: Set environment variables
runs-on: ubuntu-latest
outputs:
image_name: ${{ steps.set-output.outputs.image_name }}
image_tag: ${{ steps.set-output.outputs.image_tag }}
steps:
- name: Set image tag
id: set-output
run: |
echo 'image_name=ghcr.io/3lvia/core-github-actions-templates/gh-actions-docs' >> $GITHUB_OUTPUT
if [[ '${{ github.event_name }}' == 'push' ]]; then
echo 'image_tag=latest' >> $GITHUB_OUTPUT
else
echo 'image_tag=${{ github.sha }}' >> $GITHUB_OUTPUT
fi
build-docs-image:
name: Build image for gh-actions-docs
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
needs: [set-env]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: 'ghcr.io'
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build image
uses: docker/build-push-action@v5
with:
context: '.github/gh-actions-docs'
push: 'true'
tags: '${{ needs.set-env.outputs.image_name }}:${{ needs.set-env.outputs.image_tag }}'
cache-from: 'type=registry,ref=${{ needs.set-env.outputs.image_name }}:latest'
cache-to: 'type=inline'
generate-docs:
name: Generate action documentation
runs-on: ubuntu-latest
needs: [build-docs-image, set-env]
outputs:
readme: ${{ steps.set-output.outputs.readme }}
container:
image: '${{ needs.set-env.outputs.image_name }}:${{ needs.set-env.outputs.image_tag }}'
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: read
packages: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Generate action documentation
run: gh-actions-docs
env:
IGNORE_FILES: 'my-new-action/action.yml'
IGNORE_HEADERS: '# core-github-actions-templates,## Table of Contents'
RUN_PRETTIER: 'true'
- name: Set output
id: set-output
run: |
{
echo 'readme<<EOF'
cat README.md | base64
echo EOF
} >> "$GITHUB_OUTPUT"
commit-docs:
name: Commit action documentation on push
runs-on: ubuntu-latest
needs: [generate-docs]
permissions:
contents: write
if: github.event_name == 'push'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Get README from output
run: echo '${{ needs.generate-docs.outputs.readme }}' | base64 -d > README.md
- name: Commit changes
shell: bash
run: |
if [[ -z "$(git status --porcelain)" ]]; then
echo 'No changes to commit.'
exit 0
fi
git config user.name github-actions
git config user.email [email protected]
git add README.md
git commit -m 'Update action documentation'
git push