Skip to content

Initialize repo from template #94

Initialize repo from template

Initialize repo from template #94

name: first-time-setup
run-name: Initialize repo from template
# Todo: This workflow is not working as intended - other workflows
# like deploy.yml are still running before this one finishes.
# This workflow is triggered when a user creates a new repo from the template.
on:
# run when branch created (repo generated from template)
create:
# only keep latest run of this workflow
concurrency:
group: first-time-setup
cancel-in-progress: true
jobs:
first-time-setup:
# ensure run only once, when repo generated
if: github.run_number == 1
runs-on: ubuntu-latest
permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the
# added or changed files to the repository.
contents: write
steps:
# get main branch repo contents
- name: Checkout code
uses: actions/checkout@v3
# remove files not needed for user instance of template
- name: Remove unneeded files
run: |
rm -rf .github/FUNDING.yml \
.github/workflows/deploy.yml \
.github/workflows/docker-image.yml \
.github/workflows/publish.yml \
.github/workflows/codeql.yml \
.github/workflows/first-time-setup.yml \
tutorials \
CHANGELOG.md
# initialize environmental/config files
- name: Initialize config
run: |
cp config/.env.example config/.env
cp config/config.example.js config/config.js
cp config/servers.example.js config/servers.js
# personalize repo & project meta for user
- name: Personalize repository/project meta
run: |
sed -i "/\bCodeFactor\b/d" README.md
sed -i "/\bDocker Pulls\b/d" README.md
sed -i 's/Mirasaki\/cftools-discord-bot/${{ github.repository_owner }}\/${{ github.event.repository.name }}/g' README.md \
package.json \
package-lock.json
sed -i 's/cftools-discord-bot/${{ github.event.repository.name }}/g' README.md \
package.json \
package-lock.json
# save changed files
- name: Commit changed files
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "chore: setup repo from template"