Skip to content

Commit

Permalink
feat: implemented Pizza GitHub action (#1)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
nickytonline authored Aug 30, 2024
1 parent 0528b27 commit 84329a9
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 369 deletions.
22 changes: 17 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ For more information about the pizza-cli. check out the OpenSauced [pizza-cli](h
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.

```yaml
name: Runs the OpenSauced Pizza CLI
name: OpenSauced Pizza Action

on:
schedule:
Expand All @@ -20,16 +20,28 @@ on:
workflow_dispatch: # Allow manual triggering

jobs:
update-dev-card:
pizza-action:
runs-on: ubuntu-latest
steps:
- name: Pizza Action
uses: open-sauced/pizza-action@v1.0.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
command: "generate codeowners ./"
# optional and false by default
commit-and-push: "true"
```
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`.

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.
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.

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.

## Inputs

### `pizza-args`

Arguments to pass to the pizza CLI. Default is `generate codeowners ./`.

### `commit-and-push`

Whether to commit and push the changes made by the pizza-cli. Default is `false`.
51 changes: 33 additions & 18 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,55 @@
name: "OpenSauced Pizza Action"
description: "GitHub Action to run OpenSauced's Pizza CLI's various commands"
branding:
icon: "image"
icon: "package"
color: "orange"
inputs:
github-token:
description: "GitHub token"
required: true
pizza-args:
description: "OpenSauced Pizza CLI command to run"
default: "generate codeowners ./"
required: true
commit-and-push:
description: "Commit and push changes"
default: "false"
required: false

runs:
using: "composite"
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup Node
uses: actions/setup-node@v3
- name: Setup Go
uses: actions/setup-go@v4
with:
node-version: "20"
go-version: "1.22.5"

- name: Install pizza CLI
run: |
go install github.com/open-sauced/pizza-cli@beta
shell: bash

- name: Install dependencies
run: npm ci
- name: Check pizza CLI version
run: pizza-cli version
shell: bash
working-directory: ${{ github.action_path }}

- name: Install pizza-cli
run: go install github.com/open-sauced/pizza-cli@latest
- name: Run pizza CLI command
run: |
pwd
ls -la
pizza-cli ${{ inputs.pizza-args }}
shell: bash
working-directory: ${{ github.action_path }}
working-directory: ${{ github.workspace }}

- name: Run action
run: node ${{ github.action_path }}/index.js
- name: Commit and push changes
if: ${{ inputs.commit-and-push == 'true' }}
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git add .
git commit -m "Auto-commit from GitHub Actions"
git push
shell: bash
working-directory: ${{ github.action_path }}
env:
INPUT_GITHUB-TOKEN: ${{ inputs.github-token }}
working-directory: ${{ github.workspace }}
72 changes: 0 additions & 72 deletions index.js

This file was deleted.

Loading

0 comments on commit 84329a9

Please sign in to comment.