Skip to content

Update workflows (#68) #4

Update workflows (#68)

Update workflows (#68) #4

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: Is this still a template
id: is_template
run: echo "is_template=$(ls .github/workflows/template.yml &> /dev/null && echo true || echo false)" >> $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
if: steps.is_template.outputs.is_template == 'true'
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 temporary generated folder
run: find . -mindepth 1 ! -regex "^./\.git\(/.*\)?" ! -regex "^./temp_generated_folder\(/.*\)?" -delete
- name: Move generated project to root using rsync
run: |
rsync -av 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