Skip to content

Generate Config

Generate Config #1

name: Generate Config
on:
workflow_dispatch:
inputs:
repository-name:
description: 'The name of the repository'
required: false
default: ''
type: string
permissions:
contents: write
jobs:
check-config:
runs-on: ubuntu-latest
outputs:
skip: ${{ steps.check.outputs.skip }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Check if config has been generated
id: check
run: |
if [ -f ".github/ISSUE_TEMPLATE/issue_template_configured.txt" ]; then
echo "Config already generated"
echo "skip=true" >> $GITHUB_OUTPUT
else
echo "Config not generated yet"
echo "skip=false" >> $GITHUB_OUTPUT
fi
generate-config:
needs: check-config
if: needs.check-config.outputs.skip != 'true'
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Git
run: |
git config --global user.name 'GitHub Actions'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
- name: Run generate_config.sh
run: |
chmod +x .github/scripts/generate_config.sh
.github/scripts/generate_config.sh ${{ github.event.inputs.repository-name || github.repository }}
- name: Commit and push generated config
run: |
git add .github/ISSUE_TEMPLATE/config.yml
git add .github/ISSUE_TEMPLATE/issue_template_configured.txt
git commit -m "Update generated config.yml and issue_template_configured.txt"
git push