Skip to content

Rc/0.31.0

Rc/0.31.0 #71

name: Release branch workflow
# available flags:
## skip-e2e-tests: skip running e2e tests
## skip-build : run the test with latest version.
## skip-publish: skip publish
on:
pull_request:
types: [ labeled, opened, synchronize, unlabeled, closed ]
branches:
- main
workflow_dispatch:
# For manually trigger
inputs:
e2eBranch:
description: "Name of the e2e target branch"
required: false
default: "main"
parachainDocker:
description: "Name of the parachain docker reference"
required: false
default: "mangatasolutions/mangata-node:latest"
permissions:
contents: write
id-token: write
deployments: write
checks: write
env:
RELEASE_BRANCH_PATTERN: 'rc/'
# The following concurrency group cancels in-progress jobs or runs on pull_request events only
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
jobs:
init:
name: Global init
runs-on: ubuntu-latest
outputs:
GLOBAL_VERSION: ${{ steps.set_vars.outputs.GLOBAL_VERSION }}
GIT_BRANCH: ${{ steps.set_vars.outputs.GIT_BRANCH }}
RELEASE_BRANCH_PATTERN: ${{ steps.set_vars.outputs.RELEASE_BRANCH_PATTERN }}
RELEASE_TAG: ${{ steps.set_vars.outputs.RELEASE_TAG }}
steps:
- name: Get branch name
id: branch-name
uses: tj-actions/branch-names@v6
- name: Set global version
id: set_vars
run: |
echo "GLOBAL_VERSION=${{ github.sha }}" >> $GITHUB_OUTPUT
echo "RELEASE_BRANCH_PATTERN=${{ env.RELEASE_BRANCH_PATTERN }}" >> $GITHUB_OUTPUT
echo "GIT_BRANCH=${{ steps.branch-name.outputs.current_branch }}" | sed "s@/@-@g" >> $GITHUB_OUTPUT
echo "RELEASE_TAG=${{ steps.branch-name.outputs.current_branch }}" | sed "rc/@@g" >> $GITHUB_OUTPUT
validate-branch-name:
name: Validate release branch name
runs-on: ubuntu-latest
if: startsWith(github.head_ref, needs.init.outputs.RELEASE_BRANCH_PATTERN)
needs: [ init ]
steps:
- name: Branch name is not correct
run: exit 0
build-and-test:
needs: [init, validate-branch-name]
name: Build
uses: ./.github/workflows/reusable-build-and-test.yml
secrets: inherit
with:
version: ${{ needs.init.outputs.GLOBAL_VERSION }}
branch: ${{ needs.init.outputs.GIT_BRANCH }}
deploy-fungible:
name: Deploy fungible environment
needs: [init, validate-branch-name,build-and-test]
uses: ./.github/workflows/reusable-deploy.yml
secrets: inherit
with:
env: fungible
version: ${{ needs.init.outputs.GLOBAL_VERSION }}
cluster_name: mangata-dev-alpha
clean-up-fungible:
name: Delete fungible environment
needs: [init, validate-branch-name]
if: github.event.action == 'closed'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: google-github-actions/auth@v1
with:
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}
- name: Set up GKE credentials
uses: google-github-actions/[email protected]
with:
cluster_name: mangata-dev-alpha
location: europe-west1
- name: Delete Kubernetes namespace with resources for fungible environment
run: kubectl delete namespace pr-${{ github.event.number }}
- name: Delete GitHub Deployment environment
if: always()
uses: bobheadxi/[email protected]
with:
step: delete-env
token: ${{ secrets.GITHUB_TOKEN }}
env: pr-${{ github.event.number }}
run-e2e-test:
name: Run e2e tests
needs: [init, validate-branch-name, build-and-test]
uses: ./.github/workflows/reusable-e2e-tests.yml
secrets: inherit
with:
e2eBranch: ${{ github.event.inputs.e2eBranch }}
parachainDocker: ${{ github.event.inputs.parachainDocker }}
skipBuild: 'false'
globalVersion: ${{ needs.init.outputs.GLOBAL_VERSION }}
deploy_release_to_rococo:
name: Deploy release to rococo on merge to `main`
if: |
startsWith(github.head_ref, needs.init.outputs.RELEASE_BRANCH_PATTERN) &&
github.event.action == 'closed' && github.event.pull_request.merged == 'true'
needs: [ init ]
uses: ./.github/workflows/reusable-deploy-rococo.yml
secrets: inherit
with:
version: rococo-${{ needs.init.outputs.RELEASE_TAG }}