Initialize repo from template #18
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: first-time-setup | |
run-name: Initialize repo from 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" |