Skip to content

Use workflow inputs for release branch #6346

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

Merged
merged 1 commit into from
Jun 9, 2022
Merged
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
44 changes: 24 additions & 20 deletions .github/workflows/release-staging.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
name: Staging Release

on: workflow_dispatch
on:
workflow_dispatch:
inputs:
release-branch:
description: 'Release branch'
type: string
default: 'release'
required: true
source-branch:
description: 'Branch to release from'
type: choice
default: 'master'
required: true
options:
- master
- v8

jobs:
warn:
name: Warn If Wrong Branch
runs-on: ubuntu-latest
# Log a warning if run in a non-release branch.
if: github.ref != 'refs/heads/release' && !endsWith(github.ref, '-releasebranch')
steps:
- name: Log warning
run: echo "This workflow must be run in a release branch. It is being run in ${{ github.ref }}."
deploy:
name: Staging Release
runs-on: ubuntu-latest
# Block this workflow if run in a non-release branch.
if: github.ref == 'refs/heads/release' || endsWith(github.ref, '-releasebranch')
# Allow GITHUB_TOKEN to have write permissions
permissions:
contents: write

# Block this workflow if run on a non-release branch.
if: github.event.inputs.release-branch == 'release' || endsWith(github.event.inputs.release-branch, '-releasebranch')
steps:
- name: Set up Node (14)
uses: actions/setup-node@v2
Expand All @@ -28,20 +31,21 @@ jobs:
- name: Merge master into release
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
github-token: ${{ secrets.OSS_BOT_GITHUB_TOKEN }}
script: |
let branch = context.ref.replace("refs/heads/", "")
await github.rest.repos.merge({
const result = await github.rest.repos.merge({
owner: context.repo.owner,
repo: context.repo.repo,
base: branch,
head: 'master'
base: '${{ github.event.inputs.release-branch }}',
head: '${{ github.event.inputs.source-branch }}'
})
console.log(result)
- name: Checkout current branch (with history)
uses: actions/checkout@master
with:
# Release script requires git history and tags.
fetch-depth: 0
ref: ${{ github.event.inputs.release-branch }}
- name: Yarn install
run: yarn
- name: Publish to NPM
Expand Down