Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support push events #11

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
FROM gcr.io/pipecd/actions-plan-preview:1.7.2
FROM gcr.io/pipecd/actions-plan-preview:1.8.0
35 changes: 33 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
runs-on: ubuntu-latest
if: "github.event_name == 'pull_request'"
steps:
- uses: pipe-cd/actions-plan-preview@v1.7.2
- uses: pipe-cd/actions-plan-preview@v1.8.0
with:
address: ${{ secrets.PIPECD_API_ADDRESS }}
api-key: ${{ secrets.PIPECD_PLAN_PREVIEW_API_KEY }}
Expand All @@ -52,17 +52,48 @@ jobs:
runs-on: ubuntu-latest
if: "github.event_name == 'issue_comment' && github.event.issue.pull_request && startsWith(github.event.comment.body, '/pipecd plan-preview')"
steps:
- uses: pipe-cd/actions-plan-preview@v1.7.2
- uses: pipe-cd/actions-plan-preview@v1.8.0
with:
address: ${{ secrets.PIPECD_API_ADDRESS }}
api-key: ${{ secrets.PIPECD_PLAN_PREVIEW_API_KEY }}
token: ${{ secrets.GITHUB_TOKEN }}
```

### Push events

To run actions-plan-preview after automatically creating PRs on push events using [GITHUB_TOKEN](https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#triggering-a-workflow-from-a-workflow), it goes as follows.

```yaml
name: PipeCD

on:
push:
branches: pr-target-branch
jobs:
create-pr:
runs-on: ubuntu-latest
if: "github.event.created"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
- id: create-pr
run: |
PR=$(gh pr create --title "Update" --body "" | awk -F "/" '{print $NF}')
echo "::set-output name=pull-request-number::$PR"
- uses: pipe-cd/[email protected]
with:
address: ${{ secrets.PIPECD_API_ADDRESS }}
api-key: ${{ secrets.PIPECD_PLAN_PREVIEW_API_KEY }}
token: ${{ secrets.GITHUB_TOKEN }}
pull-request-number: ${{ steps.create-pr.outputs.pull-request-number }}
```

## Inputs

| Name | Description | Required | Default Value |
|---------------------------------|---------------------------------------------------------------------------------------------------|:--------:|:-------------:|
| address | The API address of PipeCD's control-plane. | yes | |
| api-key | The API key with READ_WRITE role used by pipectl while communicating with PipeCD's control-plane. | yes | |
| token | The GITHUB_TOKEN secret. | yes | |
| pull-request-number | PR Number needed for push event. | no | |
4 changes: 4 additions & 0 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ inputs:
description: 'Maximum amount of time to run. Default is 5m.'
required: false
default: 5m
pull-request-number:
description: 'PR Number needed for push event'
required: false

runs:
using: 'docker'
Expand All @@ -25,6 +28,7 @@ runs:
- api-key=${{ inputs.api-key }}
- token=${{ inputs.token }}
- timeout=${{ inputs.timeout }}
- pull-request-number=${{ inputs.pull-request-number }}

branding:
icon: 'eye'
Expand Down