Skip to content

Commit 84329a9

Browse files
authored
feat: implemented Pizza GitHub action (#1)
* feat: implemented Pizza GitHub action * stripping quotes from args from env vars * stripped quotes from args and bash script on the fly * chore: removed unnecessary JS files * added a commit and push script that optionally runs (false by default) * added a commit and push script that optionally runs (false by default) * removed bash script and inline git commit/push logic into action.yml * chore: added a comment about commit and push being optional * docs: added some docs around the GitHub action inputs * chore: updated GitHub marketplace icon * docs: added some docs around fetch depth 0
1 parent 0528b27 commit 84329a9

File tree

5 files changed

+50
-369
lines changed

5 files changed

+50
-369
lines changed

README.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ For more information about the pizza-cli. check out the OpenSauced [pizza-cli](h
1111
To use this action, you need to add the following to a GitHub Actions workflow file. The YAML snippet below uses the command to update your CODEOWNERS file in your repository, but replace it with whatever pizza-cli command you want to run.
1212

1313
```yaml
14-
name: Runs the OpenSauced Pizza CLI
14+
name: OpenSauced Pizza Action
1515

1616
on:
1717
schedule:
@@ -20,16 +20,28 @@ on:
2020
workflow_dispatch: # Allow manual triggering
2121

2222
jobs:
23-
update-dev-card:
23+
pizza-action:
2424
runs-on: ubuntu-latest
2525
steps:
2626
- name: Pizza Action
2727
uses: open-sauced/[email protected]
2828
with:
29-
github-token: ${{ secrets.GITHUB_TOKEN }}
30-
command: "generate codeowners ./"
29+
# optional and false by default
30+
commit-and-push: "true"
3131
```
3232
3333
We suggest you add this to a workflow file in the `.github/workflows` directory of your repository and call it something like `pizza-action.yml`.
3434

35-
Depending on the pizza-cli command you run, different things will update. For example, if you run `pizza generate codeowners ./`, it will update the CODEOWNERS file in the root of your repository.
35+
Depending on the pizza CLI command you run, different things will update. For example, if you run `pizza generate codeowners ./`, it will update the CODEOWNERS file in the root of your repository.
36+
37+
The pizza CLI's "generate codeowners ./" command requires a full repository history to accurately determine code ownership over time. Fetch-depth is set to 0 in this action to ensure all historical commits are available, allowing the command to analyze the entire project timeline and produce a comprehensive CODEOWNERS file.
38+
39+
## Inputs
40+
41+
### `pizza-args`
42+
43+
Arguments to pass to the pizza CLI. Default is `generate codeowners ./`.
44+
45+
### `commit-and-push`
46+
47+
Whether to commit and push the changes made by the pizza-cli. Default is `false`.

action.yml

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,55 @@
11
name: "OpenSauced Pizza Action"
22
description: "GitHub Action to run OpenSauced's Pizza CLI's various commands"
33
branding:
4-
icon: "image"
4+
icon: "package"
55
color: "orange"
66
inputs:
7-
github-token:
8-
description: "GitHub token"
9-
required: true
107
pizza-args:
118
description: "OpenSauced Pizza CLI command to run"
129
default: "generate codeowners ./"
1310
required: true
11+
commit-and-push:
12+
description: "Commit and push changes"
13+
default: "false"
14+
required: false
15+
1416
runs:
1517
using: "composite"
1618
steps:
1719
- name: Checkout
1820
uses: actions/checkout@v3
21+
with:
22+
fetch-depth: 0
1923

20-
- name: Setup Node
21-
uses: actions/setup-node@v3
24+
- name: Setup Go
25+
uses: actions/setup-go@v4
2226
with:
23-
node-version: "20"
27+
go-version: "1.22.5"
28+
29+
- name: Install pizza CLI
30+
run: |
31+
go install github.com/open-sauced/pizza-cli@beta
32+
shell: bash
2433

25-
- name: Install dependencies
26-
run: npm ci
34+
- name: Check pizza CLI version
35+
run: pizza-cli version
2736
shell: bash
28-
working-directory: ${{ github.action_path }}
2937

30-
- name: Install pizza-cli
31-
run: go install github.com/open-sauced/pizza-cli@latest
38+
- name: Run pizza CLI command
39+
run: |
40+
pwd
41+
ls -la
42+
pizza-cli ${{ inputs.pizza-args }}
3243
shell: bash
33-
working-directory: ${{ github.action_path }}
44+
working-directory: ${{ github.workspace }}
3445

35-
- name: Run action
36-
run: node ${{ github.action_path }}/index.js
46+
- name: Commit and push changes
47+
if: ${{ inputs.commit-and-push == 'true' }}
48+
run: |
49+
git config user.name github-actions
50+
git config user.email [email protected]
51+
git add .
52+
git commit -m "Auto-commit from GitHub Actions"
53+
git push
3754
shell: bash
38-
working-directory: ${{ github.action_path }}
39-
env:
40-
INPUT_GITHUB-TOKEN: ${{ inputs.github-token }}
55+
working-directory: ${{ github.workspace }}

index.js

Lines changed: 0 additions & 72 deletions
This file was deleted.

0 commit comments

Comments
 (0)