-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
44 additions
and
20 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,77 @@ | ||
# Workflow Name | ||
# Assign a name to the workflow. | ||
name: Template Cleanup | ||
|
||
# Trigger the workflow on push events to the master branch | ||
# Specify when this workflow is going to be triggered. | ||
on: | ||
# In this case, the workflow will be triggered whenever there is a push to the master branch. | ||
push: | ||
branches: [master] | ||
|
||
# Define jobs | ||
# Define the jobs that this workflow will perform. | ||
jobs: | ||
# Cleanup job | ||
# Declare a job named 'cleanup'. | ||
cleanup: | ||
# Job runs on the latest Ubuntu version | ||
# Specify the type of runner that the job should run on - Latest version of Ubuntu. | ||
runs-on: ubuntu-latest | ||
|
||
# Permissions | ||
# Define permissions for this job. | ||
permissions: | ||
contents: write | ||
|
||
# Conditional check | ||
# A conditional check to ensure the job runs only if the name of the repository meets the constraint. | ||
if: github.repository != 'nekofar/nextjs-lingui-template' | ||
|
||
# Steps instances | ||
# Define the steps to be followed in this job. | ||
steps: | ||
# Checkout the code. | ||
- name: Checkout code | ||
uses: actions/[email protected] | ||
|
||
# Set up Node.js environment. | ||
- name: Set up Node.js environment | ||
uses: actions/[email protected] | ||
|
||
- name: Install pnpm package manager # Install pnpm | ||
# Install pnpm package manager. | ||
- name: Install pnpm package manager | ||
uses: pnpm/[email protected] | ||
with: | ||
version: ^8 | ||
run_install: false | ||
|
||
# Clean up the repository. | ||
- name: Clean up the repository | ||
# The 'run:' statement let's you execute commands directly. | ||
run: | | ||
# Declare variables | ||
# Declare and assign local variables. | ||
NAME="$(basename $GITHUB_REPOSITORY)" | ||
VERSION='1.0.0-alpha.0' | ||
# Replace package.json name and version fields | ||
pnpm json -I -f package.json -e "this.name='${NAME}'" | ||
pnpm json -I -f package.json -e "this.version='${VERSION}'" | ||
pnpm install --no-frozen-lockfile # Install dependencies (ignoring lock file) | ||
# Use pnpm dlx json to modify package.json name and version fields. | ||
pnpm dlx json -I -f package.json -e "this.name='${NAME}'" | ||
pnpm dlx json -I -f package.json -e "this.version='${VERSION}'" | ||
pnpm dlx install --no-frozen-lockfile # Install dependencies (ignoring lock file) | ||
# Remove unnecessary files | ||
# Remove template specific files and directories. | ||
rm -rf \ | ||
.github/ISSUE_TEMPLATE \ | ||
.github/workflows/template.yml \ | ||
.github/dependabot.yml \ | ||
.github/FUNDING.yml \ | ||
.github/stale.yml \ | ||
CHANGELOG.md | ||
CHANGELOG.md \ | ||
README.md | ||
- name: Create Pull Request # Generate a pull request | ||
uses: peter-evans/[email protected] | ||
# Commit the changes made to the repository. | ||
- name: Commit files | ||
run: | | ||
git config --local user.email "[email protected]" | ||
git config --local user.name "GitHub Action" | ||
git add . | ||
git commit -m 'chore: initial template cleanup' | ||
# Push the changes to the repository. | ||
- name: Push changes | ||
uses: ad-m/github-push-action@master | ||
with: | ||
commit-message: 'chore: initial template cleanup' # Commit message | ||
branch: master | ||
github_token: ${{ secrets.GITHUB_TOKEN }} |
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
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