Skip to content

Commit de2bacb

Browse files
committed
ci: update and enhance template workflow
Updated the workflow YAML file to improve structure and readability. Changes included adding more detailed comments, giving clearer names to jobs and steps, defining sequences, and modifying push actions. Split commit and push actions into separate steps for better workflow control.
1 parent 1826f9a commit de2bacb

File tree

1 file changed

+31
-15
lines changed

1 file changed

+31
-15
lines changed

.github/workflows/template.yml

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,57 @@
1-
# Workflow Name
1+
# Assign a name to the workflow.
22
name: Template Cleanup
33

4-
# Trigger the workflow on push events to the master branch
4+
# Specify when this workflow is going to be triggered.
55
on:
6+
# In this case, the workflow will be triggered whenever there is a push to the master branch.
67
push:
78
branches: [master]
89

9-
# Define jobs
10+
# Define the jobs that this workflow will perform.
1011
jobs:
11-
# Cleanup job
12+
# Declare a job named 'cleanup'.
1213
cleanup:
13-
# Job runs on the latest Ubuntu version
14+
# Specify the type of runner that the job should run on - Latest version of Ubuntu.
1415
runs-on: ubuntu-latest
1516

16-
# Permissions
17+
# Define permissions for this job.
1718
permissions:
1819
contents: write
1920

20-
# Conditional check
21+
# A conditional check to ensure the job runs only if the name of the repository meets the constraint.
2122
if: github.repository != 'nekofar/nextjs-lingui-template'
2223

23-
# Steps instances
24+
# Define the steps to be followed in this job.
2425
steps:
26+
# Checkout the code.
2527
- name: Checkout code
2628
uses: actions/[email protected]
2729

30+
# Set up Node.js environment.
2831
- name: Set up Node.js environment
2932
uses: actions/[email protected]
3033

31-
- name: Install pnpm package manager # Install pnpm
34+
# Install pnpm package manager.
35+
- name: Install pnpm package manager
3236
uses: pnpm/[email protected]
3337
with:
3438
version: ^8
3539
run_install: false
3640

41+
# Clean up the repository.
3742
- name: Clean up the repository
43+
# The 'run:' statement let's you execute commands directly.
3844
run: |
39-
# Declare variables
45+
# Declare and assign local variables.
4046
NAME="$(basename $GITHUB_REPOSITORY)"
4147
VERSION='1.0.0-alpha.0'
4248
43-
# Replace package.json name and version fields
49+
# Use pnpm dlx json to modify package.json name and version fields.
4450
pnpm dlx json -I -f package.json -e "this.name='${NAME}'"
4551
pnpm dlx json -I -f package.json -e "this.version='${VERSION}'"
4652
pnpm dlx install --no-frozen-lockfile # Install dependencies (ignoring lock file)
4753
48-
# Remove unnecessary files
54+
# Remove template specific files and directories.
4955
rm -rf \
5056
.github/ISSUE_TEMPLATE \
5157
.github/workflows/template.yml \
@@ -55,7 +61,17 @@ jobs:
5561
CHANGELOG.md \
5662
README.md
5763
58-
- name: Create Pull Request # Generate a pull request
59-
uses: peter-evans/[email protected]
64+
# Commit the changes made to the repository.
65+
- name: Commit files
66+
run: |
67+
git config --local user.email "[email protected]"
68+
git config --local user.name "GitHub Action"
69+
git add .
70+
git commit -m 'chore: initial template cleanup'
71+
72+
# Push the changes to the repository.
73+
- name: Push changes
74+
uses: ad-m/github-push-action@master
6075
with:
61-
commit-message: 'chore: initial template cleanup' # Commit message
76+
branch: master
77+
github_token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)