|
1 | | -# Workflow Name |
| 1 | +# Assign a name to the workflow. |
2 | 2 | name: Template Cleanup |
3 | 3 |
|
4 | | -# Trigger the workflow on push events to the master branch |
| 4 | +# Specify when this workflow is going to be triggered. |
5 | 5 | on: |
| 6 | + # In this case, the workflow will be triggered whenever there is a push to the master branch. |
6 | 7 | push: |
7 | 8 | branches: [master] |
8 | 9 |
|
9 | | -# Define jobs |
| 10 | +# Define the jobs that this workflow will perform. |
10 | 11 | jobs: |
11 | | - # Cleanup job |
| 12 | + # Declare a job named 'cleanup'. |
12 | 13 | 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. |
14 | 15 | runs-on: ubuntu-latest |
15 | 16 |
|
16 | | - # Permissions |
| 17 | + # Define permissions for this job. |
17 | 18 | permissions: |
18 | 19 | contents: write |
19 | 20 |
|
20 | | - # Conditional check |
| 21 | + # A conditional check to ensure the job runs only if the name of the repository meets the constraint. |
21 | 22 | if: github.repository != 'nekofar/nextjs-lingui-template' |
22 | 23 |
|
23 | | - # Steps instances |
| 24 | + # Define the steps to be followed in this job. |
24 | 25 | steps: |
| 26 | + # Checkout the code. |
25 | 27 | - name: Checkout code |
26 | 28 | |
27 | 29 |
|
| 30 | + # Set up Node.js environment. |
28 | 31 | - name: Set up Node.js environment |
29 | 32 | |
30 | 33 |
|
31 | | - - name: Install pnpm package manager # Install pnpm |
| 34 | + # Install pnpm package manager. |
| 35 | + - name: Install pnpm package manager |
32 | 36 | |
33 | 37 | with: |
34 | 38 | version: ^8 |
35 | 39 | run_install: false |
36 | 40 |
|
| 41 | + # Clean up the repository. |
37 | 42 | - name: Clean up the repository |
| 43 | + # The 'run:' statement let's you execute commands directly. |
38 | 44 | run: | |
39 | | - # Declare variables |
| 45 | + # Declare and assign local variables. |
40 | 46 | NAME="$(basename $GITHUB_REPOSITORY)" |
41 | 47 | VERSION='1.0.0-alpha.0' |
42 | 48 |
|
43 | | - # Replace package.json name and version fields |
44 | | - pnpm json -I -f package.json -e "this.name='${NAME}'" |
45 | | - pnpm json -I -f package.json -e "this.version='${VERSION}'" |
46 | | - pnpm install --no-frozen-lockfile # Install dependencies (ignoring lock file) |
| 49 | + # Use pnpm dlx json to modify package.json name and version fields. |
| 50 | + pnpm dlx json -I -f package.json -e "this.name='${NAME}'" |
| 51 | + pnpm dlx json -I -f package.json -e "this.version='${VERSION}'" |
| 52 | + pnpm dlx install --no-frozen-lockfile # Install dependencies (ignoring lock file) |
47 | 53 |
|
48 | | - # Remove unnecessary files |
| 54 | + # Remove template specific files and directories. |
49 | 55 | rm -rf \ |
50 | 56 | .github/ISSUE_TEMPLATE \ |
51 | 57 | .github/workflows/template.yml \ |
52 | 58 | .github/dependabot.yml \ |
53 | 59 | .github/FUNDING.yml \ |
54 | 60 | .github/stale.yml \ |
55 | | - CHANGELOG.md |
| 61 | + CHANGELOG.md \ |
56 | 62 | README.md |
57 | 63 |
|
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 |
60 | 75 | with: |
61 | | - commit-message: 'chore: initial template cleanup' # Commit message |
| 76 | + branch: master |
| 77 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments