[AN-247] Edit method functionality #3008
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
name: Publish Pacts | |
on: | |
workflow_dispatch: | |
pull_request: | |
branches: [ dev ] | |
paths-ignore: | |
- 'README.md' | |
- 'integration-tests' | |
push: | |
branches: [ dev ] | |
env: | |
PUBLISH_CONTRACTS_RUN_NAME: 'publish-contracts-${{ github.event.repository.name }}-${{ github.run_id }}-${{ github.run_attempt }}' | |
CAN_I_DEPLOY_RUN_NAME: 'can-i-deploy-${{ github.event.repository.name }}-${{ github.run_id }}-${{ github.run_attempt }}' | |
PACTS_ARTIFACT: terraui-pacts-${{ github.event.repository.name }}-${{ github.run_id }} | |
PACTS_OUTPUT_DIR: pacts | |
jobs: | |
setup-and-test: | |
runs-on: ubuntu-latest | |
outputs: | |
new-tag: ${{ steps.tag.outputs.new_tag }} | |
repo-branch: ${{ steps.extract-branch.outputs.repo-branch }} | |
pact-paths: ${{ steps.locate-pacts.outputs.pact-paths }} | |
steps: | |
- uses: actions/checkout@v3 | |
- id: extract-branch | |
run: | | |
GITHUB_EVENT_NAME=${{ github.event_name }} | |
if [[ "$GITHUB_EVENT_NAME" == "push" ]]; then | |
GITHUB_REF=${{ github.ref }} | |
elif [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then | |
GITHUB_REF=refs/heads/${{ github.head_ref }} | |
elif [[ "$GITHUB_EVENT_NAME" == "merge_group" ]]; then | |
GITHUB_REF=refs/heads/${{ github.head_ref }} | |
else | |
echo "Failed to extract branch information" | |
exit 1 | |
fi | |
echo "repo-branch=${GITHUB_REF/refs\/heads\//""}" >> $GITHUB_OUTPUT | |
- name: Bump the tag to a new version | |
uses: databiosphere/github-actions/actions/[email protected] | |
id: tag | |
env: | |
DEFAULT_BUMP: patch | |
GITHUB_TOKEN: ${{ secrets.BROADBOT_TOKEN }} | |
RELEASE_BRANCHES: dev | |
WITH_V: true | |
DRY_RUN: true | |
- name: Set up Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '~20.11' | |
- name: Install dependencies | |
run: | | |
yarn install | |
- name: Run tests | |
run: yarn test "\b\w*Pact\w*\.test\.(js|ts)\b" # This matches any test file that contains the word "Pact" at the end of its name, either js or ts. | |
- name: Locate Pact files | |
id: locate-pacts | |
run: | | |
pact_paths=$(find "$PACTS_OUTPUT_DIR" -type f -name '*.json' | jq -cnR '[inputs]') | |
echo "pact-paths=$pact_paths" >> $GITHUB_OUTPUT | |
- name: Upload Pact files | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.PACTS_ARTIFACT }} | |
path: ${{ env.PACTS_OUTPUT_DIR }} | |
retention-days: 1 | |
publish-pacts: | |
runs-on: ubuntu-latest | |
needs: [setup-and-test] | |
strategy: | |
matrix: | |
pact-path: ${{ fromJson(needs.setup-and-test.outputs.pact-paths) }} | |
steps: | |
- name: Download Pact files | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ env.PACTS_ARTIFACT }} | |
path: ${{ env.PACTS_OUTPUT_DIR }} | |
- name: Encode Pact as non-breaking base64 string | |
id: encode-pact | |
run: | | |
pactB64=$(cat "${{ matrix.pact-path }}" | base64 -w 0) | |
echo "pact-b64=${pactB64}" >> $GITHUB_OUTPUT | |
- name: Publish Pact contracts | |
uses: broadinstitute/[email protected] | |
with: | |
run-name: "${{ env.PUBLISH_CONTRACTS_RUN_NAME }}-${{ matrix.pact-path }}" | |
workflow: publish-contracts.yaml | |
repo: broadinstitute/terra-github-workflows | |
ref: refs/heads/main | |
token: ${{ secrets.BROADBOT_TOKEN}} # github token for access to kick off a job in the private repo | |
inputs: '{ | |
"run-name": "${{ env.PUBLISH_CONTRACTS_RUN_NAME }}-${{ matrix.pact-path }}", | |
"pact-b64": "${{ steps.encode-pact.outputs.pact-b64 }}", | |
"repo-owner": "${{ github.repository_owner }}", | |
"repo-name": "${{ github.event.repository.name }}", | |
"repo-branch": "${{ needs.setup-and-test.outputs.repo-branch }}", | |
"release-tag": "${{ needs.setup-and-test.outputs.new-tag }}" | |
}' |