Browse Source

refactor: automate PR from develop to master

Signed-off-by: Wing-Kam Wong <wingkwong.code@gmail.com>
pull/1859/head
Wing-Kam Wong 3 years ago
parent
commit
0d194ca76e
  1. 62
      .github/workflows/pr-to-master.yml
  2. 75
      .github/workflows/release-nocodb.yml
  3. 23
      .github/workflows/sync-to-master.yml

62
.github/workflows/pr-to-master.yml

@ -0,0 +1,62 @@
name: 'PR to master branch from develop'
on:
# Triggered manually
workflow_dispatch:
inputs:
tag:
description: "Tag"
required: true
targetEnv:
description: "Target Environment"
required: true
type: choice
options:
- DEV
- PROD
# Triggered by release-nocodb.yml
workflow_call:
inputs:
tag:
description: "Tag"
required: true
type: string
targetEnv:
description: "Target Environment"
required: true
type: string
jobs:
pr-to-master:
runs-on: ubuntu-latest
steps:
- run: |
echo 'triggering pr-to-master'
- name: Checkout
uses: actions/checkout@v2
with:
ref: develop
- name: Create Pull Request
if: ${{ github.event.inputs.targetEnv == 'PROD' || inputs.targetEnv == 'PROD' }}
id: cpr
uses: repo-sync/pull-request@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
source_branch: "develop"
destination_branch: "master"
pr_title: '${{ github.event.inputs.tag || inputs.tag }} Pre-release'
pr_label: 'Bot: Automated PR,Bot: Automerge'
- name: Check outputs
if: ${{ github.event.inputs.targetEnv == 'PROD' || inputs.targetEnv == 'PROD' }}
run: |
echo "Pull Request Number - ${{ steps.cpr.outputs.pr_number }}"
echo "Pull Request URL - ${{ steps.cpr.outputs.pr_url }}"
- name: automerge
if: ${{ github.event.inputs.targetEnv == 'PROD' || inputs.targetEnv == 'PROD' }}
uses: "pascalgn/automerge-action@v0.14.3"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
PULL_REQUEST: "${{ steps.cpr.outputs.pr_number }}"
MERGE_LABELS: "Bot: Automerge"

75
.github/workflows/release-nocodb.yml

@ -6,48 +6,99 @@ on:
inputs: inputs:
tag: tag:
description: "Target Tag" description: "Target Tag"
required: true required: false
prev_tag: prev_tag:
description: "Previous Tag" description: "Previous Tag"
required: true required: false
jobs: jobs:
# Validate Branch
validate-branch:
runs-on: ubuntu-latest
steps:
- run: |
if [[ ${{ github.ref }} != 'refs/heads/master' ]]; then
echo "NocoDB Release is only allowed to run on master branch"
exit 1
fi
# Process Input
process-input:
runs-on: ubuntu-latest
needs: validate-branch
outputs:
target_tag: ${{ steps.process-input.outputs.target_tag }}
prev_tag: ${{ steps.process-input.outputs.prev_tag }}
steps:
- id: process-input
name: process-input
run: |
TARGET_TAG=${{github.event.inputs.tag}}
PREV_TAG=${{github.event.inputs.prev_tag}}
if [[ ${PREV_TAG} == '' ]]; then
# fetch the latest version
PREV_TAG=$(basename $(curl -fs -o/dev/null -w %{redirect_url} https://github.com/nocodb/nocodb/releases/latest))
fi
if [[ ${TARGET_TAG} == '' ]]; then
# bump the version from PREV_TAG
TARGET_TAG=$(echo ${PREV_TAG} | awk -F. -v OFS=. '{$NF += 1 ; print}')
fi
echo target version: ${TARGET_TAG}
echo previous version: ${PREV_TAG}
echo "::set-output name=target_tag::${TARGET_TAG}"
echo "::set-output name=prev_tag::${PREV_TAG}"
- name: Verify
run : |
echo ${{ steps.process-input.outputs.target_tag }}
# Merge develop to master
pr-to-master:
needs: process-input
uses: ./.github/workflows/pr-to-master.yml
with:
tag: ${{ needs.process-input.outputs.target_tag }}
targetEnv: ${{ github.event.inputs.targetEnv || 'PROD' }}
# Close all issues with target tags 'Fixed' & 'Resolved' # Close all issues with target tags 'Fixed' & 'Resolved'
close-fixed-issues: close-fixed-issues:
needs: [pr-to-master, process-input]
uses: ./.github/workflows/release-close-issue.yml uses: ./.github/workflows/release-close-issue.yml
with: with:
issue_label: 'Status: Fixed' issue_label: 'Status: Fixed'
version: ${{ github.event.inputs.tag }} version: ${{ needs.process-input.outputs.target_tag }}
close-resolved-issues: close-resolved-issues:
needs: close-fixed-issues needs: [close-fixed-issues, process-input]
uses: ./.github/workflows/release-close-issue.yml uses: ./.github/workflows/release-close-issue.yml
with: with:
issue_label: 'Status: Resolved' issue_label: 'Status: Resolved'
version: ${{ github.event.inputs.tag }} version: ${{ needs.process-input.outputs.target_tag }}
# Build, install, publish frontend and backend to npm # Build, install, publish frontend and backend to npm
release-npm: release-npm:
needs: close-resolved-issues needs: [close-resolved-issues, process-input]
uses: ./.github/workflows/release-npm.yml uses: ./.github/workflows/release-npm.yml
with: with:
tag: ${{ github.event.inputs.tag }} tag: ${{ needs.process-input.outputs.target_tag }}
targetEnv: ${{ github.event.inputs.targetEnv || 'PROD' }} targetEnv: ${{ github.event.inputs.targetEnv || 'PROD' }}
secrets: secrets:
NPM_TOKEN: "${{ secrets.NPM_TOKEN }}" NPM_TOKEN: "${{ secrets.NPM_TOKEN }}"
# Draft Release Note # Draft Release Note
release-draft-note: release-draft-note:
needs: release-npm needs: [release-npm, process-input]
uses: ./.github/workflows/release-draft.yml uses: ./.github/workflows/release-draft.yml
with: with:
tag: ${{ github.event.inputs.tag }} tag: ${{ needs.process-input.outputs.target_tag }}
prev_tag: ${{ github.event.inputs.prev_tag }} prev_tag: ${{ needs.process-input.outputs.prev_tag }}
# Build docker image and push to docker hub # Build docker image and push to docker hub
release-docker: release-docker:
needs: release-draft-note needs: [release-draft-note, process-input]
uses: ./.github/workflows/release-docker.yml uses: ./.github/workflows/release-docker.yml
with: with:
tag: ${{ github.event.inputs.tag }} tag: ${{ needs.process-input.outputs.target_tag }}
targetEnv: ${{ github.event.inputs.targetEnv || 'PROD' }} targetEnv: ${{ github.event.inputs.targetEnv || 'PROD' }}
secrets: secrets:
DOCKERHUB_USERNAME: "${{ secrets.DOCKERHUB_USERNAME }}" DOCKERHUB_USERNAME: "${{ secrets.DOCKERHUB_USERNAME }}"

23
.github/workflows/sync-to-master.yml

@ -0,0 +1,23 @@
name: 'Sync changes to master branch from develop'
on:
# Triggered manually
workflow_dispatch:
# Triggered by release-nocodb.yml
workflow_call:
jobs:
sync-to-master:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Merge from develop to master
uses: wingkwong/gh-action-nightly-merge@master
with:
stable_branch: 'develop'
development_branch: 'master'
allow_ff: true
allow_forks: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Loading…
Cancel
Save