From 2426b5724771b8a89386d272ca1fcdfc42bdcb6d Mon Sep 17 00:00:00 2001 From: Matt Calhoun Date: Mon, 22 Jan 2024 17:14:15 -0500 Subject: [PATCH 1/3] add back missing workflow --- .github/workflows/main-branch.yml | 129 ++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 .github/workflows/main-branch.yml diff --git a/.github/workflows/main-branch.yml b/.github/workflows/main-branch.yml new file mode 100644 index 0000000..afe8379 --- /dev/null +++ b/.github/workflows/main-branch.yml @@ -0,0 +1,129 @@ +name: |- + Main branch workflow + + Lint `action.yml`, run tests and draft release + + ### Usage + + Create in your repo __`.github/workflows/main.yaml`__ + + ```yaml + name: Main branch + on: + push: + branches: [ main ] + + permissions: + contents: write + + jobs: + perform: + uses: cloudposse/github-actions-workflows-github-action-composite/.github/workflows/main-branch.yml@main + with: + organization: "$\{\{ github.event.repository.owner.login \}\}" + repository: "$\{\{ github.event.repository.name \}\}" + secrets: + github-private-actions-pat: "$\{\{ secrets.PUBLIC_REPO_ACCESS_TOKEN \}\}" + ``` + +on: + workflow_call: + inputs: + organization: + description: "Repository owner organization (ex. acme for repo acme/example)" + required: false + default: ${{ github.event.repository.owner.login }} + type: string + repository: + description: "Repository name (ex. example for repo acme/example)" + required: false + default: ${{ github.event.repository.name }} + type: string + ref: + description: "The fully-formed ref of the branch or tag that triggered the workflow run" + required: false + default: ${{ github.ref }} + type: string + tests-prefix: + description: "Workflows file name prefix to run as tests" + required: false + type: string + default: "test-*" + secrets: + github-private-actions-pat: + description: "Github PAT allow to trigger workflows for testing" + required: true + +permissions: + contents: write + +concurrency: + group: ${{ github.workflow }} + cancel-in-progress: false + +jobs: + context: + runs-on: ubuntu-latest + steps: + - name: Checkout main + uses: actions/checkout@v3 + + - name: Workflows + id: workflows + shell: bash + run: | + TEST_FILES=$(find ./.github/workflows -type f -name "${{ inputs.tests-prefix }}" -exec basename {} \; | jq -MRc -s '. | split("\n") | map(select(. != ""))') + echo "list=${TEST_FILES}" >> $GITHUB_OUTPUT + + outputs: + tests: ${{ steps.workflows.outputs.list }} + + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: YAML file validation + uses: mpoc/nexus-validate-using-remote-schema-action@main + with: + api-endpoint: https://json.schemastore.org/github-action.json + yaml-file: action.yml + + test: + runs-on: ubuntu-latest + if: ${{ needs.context.outputs.tests != '[]' }} + strategy: + matrix: + env: ${{ fromJson(needs.context.outputs.tests) }} + needs: [lint, context] + steps: + - uses: convictional/trigger-workflow-and-wait@v1.6.5 + with: + owner: ${{ inputs.organization }} + repo: ${{ inputs.repository }} + github_token: ${{ secrets.github-private-actions-pat }} + workflow_file_name: ${{ matrix.env }} + ref: ${{ inputs.ref }} + wait_interval: 10 + client_payload: "{}" + propagate_failure: true + trigger_workflow: true + wait_workflow: true + + draft_release: + name: draft release + runs-on: ubuntu-latest + needs: [test, lint] + if: ${{ always() && ( needs.test.result == 'success' || needs.test.result == 'skipped' ) && needs.lint.result == 'success' }} + permissions: + contents: write + steps: + - name: Create/Update Draft release + uses: release-drafter/release-drafter@v5 + with: + publish: false + prerelease: false + config-name: configs/draft-release.yml + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 4296ec5b1466e43db9872222bfcc71639ae1c906 Mon Sep 17 00:00:00 2001 From: Matt Calhoun Date: Mon, 22 Jan 2024 17:27:22 -0500 Subject: [PATCH 2/3] add back missing workflow --- .github/workflows/main-branch.yml | 133 +++--------------------------- 1 file changed, 10 insertions(+), 123 deletions(-) diff --git a/.github/workflows/main-branch.yml b/.github/workflows/main-branch.yml index afe8379..3251552 100644 --- a/.github/workflows/main-branch.yml +++ b/.github/workflows/main-branch.yml @@ -1,129 +1,16 @@ -name: |- - Main branch workflow - - Lint `action.yml`, run tests and draft release - - ### Usage - - Create in your repo __`.github/workflows/main.yaml`__ - - ```yaml - name: Main branch - on: - push: - branches: [ main ] - - permissions: - contents: write - - jobs: - perform: - uses: cloudposse/github-actions-workflows-github-action-composite/.github/workflows/main-branch.yml@main - with: - organization: "$\{\{ github.event.repository.owner.login \}\}" - repository: "$\{\{ github.event.repository.name \}\}" - secrets: - github-private-actions-pat: "$\{\{ secrets.PUBLIC_REPO_ACCESS_TOKEN \}\}" - ``` - +name: Main branch on: - workflow_call: - inputs: - organization: - description: "Repository owner organization (ex. acme for repo acme/example)" - required: false - default: ${{ github.event.repository.owner.login }} - type: string - repository: - description: "Repository name (ex. example for repo acme/example)" - required: false - default: ${{ github.event.repository.name }} - type: string - ref: - description: "The fully-formed ref of the branch or tag that triggered the workflow run" - required: false - default: ${{ github.ref }} - type: string - tests-prefix: - description: "Workflows file name prefix to run as tests" - required: false - type: string - default: "test-*" - secrets: - github-private-actions-pat: - description: "Github PAT allow to trigger workflows for testing" - required: true + push: + branches: [main] permissions: contents: write -concurrency: - group: ${{ github.workflow }} - cancel-in-progress: false - jobs: - context: - runs-on: ubuntu-latest - steps: - - name: Checkout main - uses: actions/checkout@v3 - - - name: Workflows - id: workflows - shell: bash - run: | - TEST_FILES=$(find ./.github/workflows -type f -name "${{ inputs.tests-prefix }}" -exec basename {} \; | jq -MRc -s '. | split("\n") | map(select(. != ""))') - echo "list=${TEST_FILES}" >> $GITHUB_OUTPUT - - outputs: - tests: ${{ steps.workflows.outputs.list }} - - lint: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: YAML file validation - uses: mpoc/nexus-validate-using-remote-schema-action@main - with: - api-endpoint: https://json.schemastore.org/github-action.json - yaml-file: action.yml - - test: - runs-on: ubuntu-latest - if: ${{ needs.context.outputs.tests != '[]' }} - strategy: - matrix: - env: ${{ fromJson(needs.context.outputs.tests) }} - needs: [lint, context] - steps: - - uses: convictional/trigger-workflow-and-wait@v1.6.5 - with: - owner: ${{ inputs.organization }} - repo: ${{ inputs.repository }} - github_token: ${{ secrets.github-private-actions-pat }} - workflow_file_name: ${{ matrix.env }} - ref: ${{ inputs.ref }} - wait_interval: 10 - client_payload: "{}" - propagate_failure: true - trigger_workflow: true - wait_workflow: true - - draft_release: - name: draft release - runs-on: ubuntu-latest - needs: [test, lint] - if: ${{ always() && ( needs.test.result == 'success' || needs.test.result == 'skipped' ) && needs.lint.result == 'success' }} - permissions: - contents: write - steps: - - name: Create/Update Draft release - uses: release-drafter/release-drafter@v5 - with: - publish: false - prerelease: false - config-name: configs/draft-release.yml - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + perform: + uses: cloudposse/github-actions-workflows-github-action-composite/.github/workflows/main-branch.yml@main + with: + organization: "${{ github.event.repository.owner.login }}" + repository: "${{ github.event.repository.name }}" + secrets: + github-private-actions-pat: "${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}" From 91f93cfe6df496702904a48c95a46e61c74eeb36 Mon Sep 17 00:00:00 2001 From: Matt Calhoun Date: Tue, 20 Feb 2024 14:20:24 -0500 Subject: [PATCH 3/3] add additional test --- .github/workflows/build-and-test.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index c55fd96..faf5f72 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -93,3 +93,7 @@ jobs: with: expected: '{"prop1":"components/terraform","prop2":"arn:aws:secretsmanager:us-east-1:000000000000:secret:MySecret-PlMes3"}' actual: ${{ steps.get-setting.outputs.settings}} + - uses: nick-fields/assert-action@v1 + with: + expected: components/terraform + actual: ${{ steps.get-setting.outputs.settings.prop1}}