Browse Source

Merge pull request #1859 from nocodb/refactor/github-action

feat: automate PR process from develop to master in release
pull/1870/head
navi 2 years ago committed by GitHub
parent
commit
331d7cd8b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 62
      .github/workflows/pr-to-master.yml
  2. 75
      .github/workflows/release-nocodb.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:
tag:
description: "Target Tag"
required: true
required: false
prev_tag:
description: "Previous Tag"
required: true
required: false
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-fixed-issues:
needs: [pr-to-master, process-input]
uses: ./.github/workflows/release-close-issue.yml
with:
issue_label: 'Status: Fixed'
version: ${{ github.event.inputs.tag }}
version: ${{ needs.process-input.outputs.target_tag }}
close-resolved-issues:
needs: close-fixed-issues
needs: [close-fixed-issues, process-input]
uses: ./.github/workflows/release-close-issue.yml
with:
issue_label: 'Status: Resolved'
version: ${{ github.event.inputs.tag }}
version: ${{ needs.process-input.outputs.target_tag }}
# Build, install, publish frontend and backend to npm
release-npm:
needs: close-resolved-issues
needs: [close-resolved-issues, process-input]
uses: ./.github/workflows/release-npm.yml
with:
tag: ${{ github.event.inputs.tag }}
tag: ${{ needs.process-input.outputs.target_tag }}
targetEnv: ${{ github.event.inputs.targetEnv || 'PROD' }}
secrets:
NPM_TOKEN: "${{ secrets.NPM_TOKEN }}"
# Draft Release Note
release-draft-note:
needs: release-npm
needs: [release-npm, process-input]
uses: ./.github/workflows/release-draft.yml
with:
tag: ${{ github.event.inputs.tag }}
prev_tag: ${{ github.event.inputs.prev_tag }}
tag: ${{ needs.process-input.outputs.target_tag }}
prev_tag: ${{ needs.process-input.outputs.prev_tag }}
# Build docker image and push to docker hub
release-docker:
needs: release-draft-note
needs: [release-draft-note, process-input]
uses: ./.github/workflows/release-docker.yml
with:
tag: ${{ github.event.inputs.tag }}
tag: ${{ needs.process-input.outputs.target_tag }}
targetEnv: ${{ github.event.inputs.targetEnv || 'PROD' }}
secrets:
DOCKERHUB_USERNAME: "${{ secrets.DOCKERHUB_USERNAME }}"

Loading…
Cancel
Save