diff --git a/Dockerfile b/Dockerfile index a09d8ed..f53335c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1 +1 @@ -FROM gcr.io/pipecd/actions-plan-preview:1.7.2 +FROM gcr.io/pipecd/actions-plan-preview:1.8.0 diff --git a/README.md b/README.md index 1dde30c..fa6ddf6 100644 --- a/README.md +++ b/README.md @@ -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 }} @@ -52,13 +52,43 @@ 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/actions-plan-preview@v1.8.0 + 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 | @@ -66,3 +96,4 @@ jobs: | 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 | | diff --git a/action.yaml b/action.yaml index ad62045..8117dc0 100644 --- a/action.yaml +++ b/action.yaml @@ -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' @@ -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'