Skip to content

Instantly share code, notes, and snippets.

@saitho
Last active June 11, 2021 09:00
Show Gist options
  • Save saitho/c50ccba8284756f3a91b9e82734aea51 to your computer and use it in GitHub Desktop.
Save saitho/c50ccba8284756f3a91b9e82734aea51 to your computer and use it in GitHub Desktop.
name: Triggered by PR approval
on:
pull_request_review:
types: [submitted]
# execute integration test when maintainer approves pull request ("success" signal of manual workflow)
integrationtest:
name: Run integration test
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false
steps:
- run: if [ ${{ github.event.review.state }} != 'approved' ]; then exit 1; else exit 0; fi
- run: echo "Run Integration tests here..."
name: Triggered by label
on:
pull_request:
types: [labeled, synchronize]
jobs:
# execute integration test when maintainer sets label "action/integration-test" as "success" signal of manual workflow
integrationtest:
name: Integration Test
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false
steps:
- run: if [ ${{ contains( github.event.pull_request.labels.*.name, 'action/integration-test') }} == false ]; then exit 1; else exit 0; fi
- run: echo "Run Integration tests here..."
name: Test
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
name: Lint Code Base
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Lint Code Base
uses: docker://github/super-linter:v3
env:
VALIDATE_ALL_CODEBASE: false
DEFAULT_BRANCH: main
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
sonarcloud:
name: SonarCloud
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
unittest:
name: Run unit tests
runs-on: ubuntu-latest
steps:
- run: echo "Run Unit tests here..."
# notify maintainer that that they need to do a code review ("trigger" manual workflow)
assignreviewer:
name: Assign Reviewer
runs-on: ubuntu-latest
needs: sonarcloud
steps:
- uses: AveryCameronUofR/add-reviewer-gh-action@1.0.3
with:
reviewers: "YOUR-USERNAME"
token: ${{ secrets.GITHUB_TOKEN }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment