Skip to content

No need to check if it's template #12

No need to check if it's template

No need to check if it's template #12

Workflow file for this run

name: Execute Copier
on: [push]
permissions: write-all
jobs:
execute-copier:
if: ${{ !contains(github.repository, '/python-template') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.head_ref }}
- name: Get data from GitHub API
id: github
run: |
response=$(gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/users/${{ github.repository_owner }})
twitter=$(echo "$response" | jq -r .twitter_username)
email=$(echo "$response" | jq -r .email)
full_name=$(echo "$response" | jq -r .name)
echo "twitter=$twitter" >> $GITHUB_OUTPUT
echo "email=$email" >> $GITHUB_OUTPUT
echo "full_name=$full_name" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get Repository Name
id: repository
run: echo "name=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}' | tr '-' '_' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT
- name: Install uv
uses: astral-sh/setup-uv@v2
with:
version: "0.4.12"
- name: Install dependencies
run: uv sync --frozen
- name: Run Copier
run: |
uv run copier copy . . --trust --defaults \
--data project_name=${{ steps.repository.outputs.name }} \
--data full_name="${{ steps.github.outputs.full_name }}" \
--data email=${{ steps.github.outputs.email }} \
--data github=${{ github.repository_owner }} \
--data twitter=${{ steps.github.outputs.twitter }}
- name: Rename generated folder to a temporary name
run: |
GENERATED_FOLDER="${{ steps.repository.outputs.name }}"
mv $GENERATED_FOLDER temp_generated_folder
- name: Remove all files and directories in the root except .git, .github, and temporary generated folder
run: find . -mindepth 1 ! -regex "^./\.git\(/.*\)?" ! -regex "^./\.github\(/.*\)?" ! -regex "^./temp_generated_folder\(/.*\)?" -delete
- name: Move generated project to root using rsync
run: |
rsync -av --exclude='.github' temp_generated_folder/ ./
rm -rf temp_generated_folder
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "First commit 🎉"
commit_options: --amend --no-edit
push_options: --force