adding examples for push and release

Signed-off-by: vsoch <vsochat@stanford.edu>
This commit is contained in:
vsoch
2020-03-17 11:36:44 -06:00
parent d0c1b9ddb0
commit 4ae1c5e25c
3 changed files with 69 additions and 1 deletions

View File

@@ -50,7 +50,9 @@ the pull request. The example is [deployed here](https://github.com/vsoch/pull-r
## Examples
Let's say that we are opening a pull request on the [publish]() event. This would mean
Example workflows are provided in [examples](examples), and please contribute any
examples that you might have to help other users! We will walk through a basic
example here for a niche case. Let's say that we are opening a pull request on the release event. This would mean
that the payload's branch variable would be null. We would need to define `PULL_REQUEST_FROM`. How would
we do that? We can [set environment variables](https://help.github.com/en/actions/reference/development-tools-for-github-actions#set-an-environment-variable-set-env) for next steps. Here is an example:

18
examples/push-example.yml Normal file
View File

@@ -0,0 +1,18 @@
name: Pull Request on Branch Push
on:
push:
branches-ignore:
- staging
- launchpad
- production
jobs:
auto-pull-request:
name: PullRequestAction
runs-on: ubuntu-latest
steps:
- name: pull-request-action
uses: vsoch/pull-request-action@add/support-null-branch
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH_PREFIX: "update/"
PULL_REQUEST_BRANCH: "master"

View File

@@ -0,0 +1,48 @@
on:
release:
types:
- published
jobs:
persist-new-suite-yml:
name: Commit Suite Release YML
runs-on: ubuntu-latest
steps:
# Likely other steps go here
- name: Set BRANCH_NAME
run: |
tag_name=${{github.event.release.tag_name}}
echo "Tag: $tag_name"
version=$(echo "$tag_name" | sed 's/^v//')
echo "Version: $version"
echo "::set-output name=suite_version::${version}"
echo "::set-output name=suite_update_branch::suite_${version}"
id: data
- name: Permanently save the new suite release
run: |
mkdir -p releases
new_suite_version_yml="releases/suite_${{ steps.data.outputs.suite_version }}.yml"
echo "Suite target file: $new_suite_version_yml"
cp suite.yml "${new_suite_version_yml}"
git add "${new_suite_version_yml}"
git commit -m "Suite v${{ steps.data.outputs.suite_version }} auto-commit of new release files"
- name: Push files
run: |
git push --force "https://${{ github.actor }}:${{secrets.GITHUB_TOKEN}}@github.com/${{ github.repository }}.git" "HEAD:${{ steps.data.outputs.suite_update_branch }}"
- name: Open a PR to the default branch
uses: vsoch/pull-request-action@1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PULL_REQUEST_FROM_BRANCH: "${{ steps.data.outputs.suite_update_branch }}"
PULL_REQUEST_BRANCH: master
PULL_REQUEST_TITLE: "Action: Update suite release file for v${{ steps.data.outputs.suite_version }}"
PULL_REQUEST_BODY: "Auto-generated PR!"