-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix cicd to support forked repo (#145)
* fix cicd to support forked repo * added support for pr label checks
- Loading branch information
Showing
2 changed files
with
65 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,76 @@ | ||
name: Release on Dev | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- closed | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
|
||
Release: | ||
|
||
if: github.event.pull_request.merged == true | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
label: ${{ github.event.pull_request.labels.*.name }} | ||
|
||
steps: | ||
|
||
- if: startsWith(matrix.label, 'release:') | ||
name: Retrieving Release Type | ||
- name: Check Patch Label | ||
id: check_pr_labels_patch | ||
uses: shioyang/[email protected] | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
labels: '["release:patch"]' | ||
|
||
- name: Check Minor Label | ||
id: check_pr_labels_minor | ||
uses: shioyang/[email protected] | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
labels: '["release:minor"]' | ||
|
||
- name: Check Major Label | ||
id: check_pr_labels_major | ||
uses: shioyang/[email protected] | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
labels: '["release:major"]' | ||
|
||
- name: Release Type | ||
run: | | ||
release_type=`echo ${{matrix.label}} | awk -F':' '{print $NF}'` | ||
echo "RELEASE_TYPE=${release_type}" >> $GITHUB_ENV | ||
echo "Releasing: ${release_type}" | ||
if [ ${MAJOR} == "true" ] ; then | ||
echo "RELEASE_TYPE=major" >> $GITHUB_ENV | ||
elif [ ${MINOR} == "true" ] ; then | ||
echo "RELEASE_TYPE=minor" >> $GITHUB_ENV | ||
elif [ ${PATCH} == "true" ] ; then | ||
echo "RELEASE_TYPE=patch" >> $GITHUB_ENV | ||
else | ||
echo "RELEASE_TYPE=none" >> $GITHUB_ENV | ||
fi | ||
env: | ||
PATCH: ${{ steps.check_pr_labels_patch.outputs.result }} | ||
MINOR: ${{ steps.check_pr_labels_minor.outputs.result }} | ||
MAJOR: ${{ steps.check_pr_labels_major.outputs.result }} | ||
|
||
- name: Testing Release Type | ||
if: env.RELEASE_TYPE == 'none' | ||
uses: actions/github-script@v3 | ||
with: | ||
script: | | ||
core.setFailed('Release labels were not present in the PR!') | ||
- if: startsWith(matrix.label, 'release:') | ||
name: Inject slug/short variables | ||
- name: Inject slug/short variables | ||
uses: rlespinasse/[email protected] | ||
|
||
- if: startsWith(matrix.label, 'release:') | ||
name: Checkout | ||
- name: Checkout | ||
uses: actions/[email protected] | ||
|
||
- if: startsWith(matrix.label, 'release:') | ||
name: Bump version and push tag | ||
- name: Bump version and push tag | ||
id: tag_version | ||
uses: mathieudutour/[email protected] | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
default_bump: ${{ env.RELEASE_TYPE }} | ||
|
||
- if: startsWith(matrix.label, 'release:') | ||
name: Creating Github Release | ||
- name: Creating Github Release | ||
uses: ncipollo/release-action@v1 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
@@ -54,43 +81,37 @@ jobs: | |
name: Release ${{ steps.tag_version.outputs.new_tag }} | ||
body: ${{ steps.changelog.outputs.changelog }} | ||
|
||
- if: startsWith(matrix.label, 'release:') | ||
name: Build Cloud Runners | ||
- name: Build Cloud Runners | ||
run: | | ||
gh workflow run -R ${{ secrets.WF_REPO }} ${{ secrets.WF_NAME }} -r main -f environment=dev -f version=${{ steps.tag_version.outputs.new_tag }} | ||
env: | ||
GITHUB_TOKEN: ${{secrets.GH_API_TOKEN}} | ||
|
||
- if: startsWith(matrix.label, 'release:') | ||
name: Setup Environment | ||
- name: Setup Environment | ||
run: | | ||
echo "BOTNAME=Test-at-Scale Deployment Status: Version ${{ steps.tag_version.outputs.new_tag }} to dev" >> $GITHUB_ENV | ||
- if: startsWith(matrix.label, 'release:') | ||
name: Setup Docker Image Tags | ||
- name: Setup Docker Image Tags | ||
run: | | ||
echo "NUCLEUS_TAGS=lambdatest/nucleus:dev-base","lambdatest/nucleus:${{ steps.tag_version.outputs.new_tag }}-base" >> $GITHUB_ENV | ||
echo "SYNAPSE_TAGS=lambdatest/synapse:dev","lambdatest/synapse:${{ steps.tag_version.outputs.new_tag }}" >> $GITHUB_ENV | ||
- if: startsWith(matrix.label, 'release:') | ||
name: Docker Login | ||
- name: Docker Login | ||
uses: docker/[email protected] | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_TOKEN }} | ||
logout: true | ||
|
||
- if: startsWith(matrix.label, 'release:') | ||
name: Build and push Nucleus images | ||
- name: Build and push Nucleus images | ||
uses: docker/[email protected] | ||
with: | ||
context: . | ||
tags: ${{ env.NUCLEUS_TAGS }} | ||
file: build/nucleus/Dockerfile | ||
push: true | ||
|
||
- if: startsWith(matrix.label, 'release:') | ||
name: Build and push Synapse images | ||
- name: Build and push Synapse images | ||
uses: docker/[email protected] | ||
with: | ||
context: . | ||
|