diff --git a/.github/actions/download-artifact/action.yaml b/.github/actions/download-artifact/action.yaml new file mode 100644 index 000000000..15b3f25e7 --- /dev/null +++ b/.github/actions/download-artifact/action.yaml @@ -0,0 +1,41 @@ +name: 'Download artifact from another workflow in a workflow triggered by workflow_run' +inputs: + artifact_name: + required: true + type: string + default: 'emqx-source' + archive_format: + required: false + type: string + default: 'zip' + +defaults: + run: + shell: 'bash -Eeuo pipefail {0}' + +runs: + using: composite + steps: + - name: Download artifact + uses: actions/github-script@v6 + with: + script: | + let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: context.payload.workflow_run.id, + }); + let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => { + return artifact.name == "${{ inputs.artifact_name }}" + })[0]; + let download = await github.rest.actions.downloadArtifact({ + owner: context.repo.owner, + repo: context.repo.repo, + artifact_id: matchArtifact.id, + archive_format: '${{ inputs.archive_format }}', + }); + let fs = require('fs'); + fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/data.zip`, Buffer.from(download.data)); + - name: Unzip artifact + shell: bash + run: unzip -o -q data.zip diff --git a/.github/actions/pr-sanity-checks/action.yaml b/.github/actions/pr-sanity-checks/action.yaml index 7a6a02f1d..24e46a52c 100644 --- a/.github/actions/pr-sanity-checks/action.yaml +++ b/.github/actions/pr-sanity-checks/action.yaml @@ -29,6 +29,9 @@ runs: apt-get install -y shellcheck ./scripts/shellcheck.sh echo "success" + - name: Ensure rebar + shell: bash + run: make ensure-rebar3 - name: Check Erlang code formatting shell: bash run: ./scripts/check-format.sh diff --git a/.github/workflows/_pr_entrypoint.yaml b/.github/workflows/_pr_entrypoint.yaml index 908a2af5f..a1ae4ce15 100644 --- a/.github/workflows/_pr_entrypoint.yaml +++ b/.github/workflows/_pr_entrypoint.yaml @@ -1,11 +1,10 @@ name: PR Entrypoint on: - push: pull_request: jobs: - entrypoint: + sanity-checks: runs-on: aws-amd64 container: ghcr.io/emqx/emqx-builder/5.1-1:1.14.5-25.3.2-1-ubuntu22.04 @@ -14,4 +13,9 @@ jobs: with: fetch-depth: 0 - uses: ./.github/actions/pr-sanity-checks + - uses: actions/upload-artifact@v3 + with: + name: emqx-source + path: . + retention-days: 1 diff --git a/.github/workflows/apps_version_check.yaml b/.github/workflows/apps_version_check.yaml index d8247d6d1..a0d445f98 100644 --- a/.github/workflows/apps_version_check.yaml +++ b/.github/workflows/apps_version_check.yaml @@ -1,14 +1,18 @@ name: Check Apps Version -# on: [pull_request] +on: + workflow_run: + workflows: + - PR Entrypoint + types: + - completed jobs: check_apps_version: - runs-on: ubuntu-22.04 + runs-on: aws-amd64 + if: github.event.workflow_run.conclusion == 'success' steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 + - uses: ./.github/actions/download-artifact - name: Check apps version run: ./scripts/apps-version-check.sh