Skip to content

Instantly share code, notes, and snippets.

@Julian88Tex
Created December 23, 2022 21:01
Show Gist options
  • Save Julian88Tex/98c91845eacf75c53cc2246c244cad5c to your computer and use it in GitHub Desktop.
Save Julian88Tex/98c91845eacf75c53cc2246c244cad5c to your computer and use it in GitHub Desktop.
Example of triggering a reusable test.yml GitHub Action workflow from a main.yml (CumulusCI)
name: Main
on:
push:
branches:
- 'main'
env:
CUMULUSCI_KEYCHAIN_CLASS: cumulusci.core.keychain.EnvironmentProjectKeychain
CUMULUSCI_SERVICE_github: ${{ secrets.CUMULUSCI_SERVICE_github }}
jobs:
release_beta:
uses: ./.github/workflows/tests.yml
with:
ci_flow: release_beta
secrets:
sfdx_auth_url_julian: ${{ secrets.SFDX_AUTH_URL_JULIAN }}
CUMULUSCI_KEYCHAIN_CLASS: cumulusci.core.keychain.EnvironmentProjectKeychain
CUMULUSCI_SERVICE_github: ${{ secrets.CUMULUSCI_SERVICE_github }}
name: Tests
on:
push:
branches:
- '**'
workflow_call:
inputs:
ci_flow:
description: 'CumulusCI flow name'
required: true
type: string
# could never get this default value to work
default: 'ci_feature'
secrets:
sfdx_auth_url_julian:
required: true
CUMULUSCI_KEYCHAIN_CLASS:
CUMULUSCI_SERVICE_github:
env:
CUMULUSCI_KEYCHAIN_CLASS: cumulusci.core.keychain.EnvironmentProjectKeychain
CUMULUSCI_SERVICE_github: ${{ secrets.CUMULUSCI_SERVICE_github }}
jobs:
apex_unit_tests:
name: 'Run Apex Unit Tests'
runs-on: ubuntu-latest
steps:
# Excluding a lot here since the focus is on using the reusable parameters below
# Had to include this step which does a null check as well as converts the input variable into a step variable since I could never get the "default" veriable to work.
# I think these don't actually work with workflow calls like they do with workflow dispatch.
- name: Check if ci_flow is empty otherwise set to ci_feature
run: |
if [ -z "${{ inputs.ci_flow }}" ]; then
echo "ci_flow=ci_feature" >> $GITHUB_OUTPUT
else
echo "ci_flow=${{ inputs.ci_flow }}" >> $GITHUB_OUTPUT
fi
id: ci_value_check
- name: Deploy and Run Tests
run: |
cci flow run ${{ steps.ci_value_check.outputs.ci_flow }} -o run_tests__managed true --org dev --delete-org
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment