From 84f05c06bc5609e74c2dcf70adb885c4cf76731e Mon Sep 17 00:00:00 2001 From: liammcinroy <1899809+liammcinroy@users.noreply.github.com> Date: Thu, 28 Mar 2024 11:22:28 -0600 Subject: [PATCH 1/9] new action (untested) --- .env | 2 +- .github/workflows/pull_request_target.yml | 14 -------------- .github/workflows/push.yml | 21 --------------------- README.md | 20 +++++++++++++------- action.yml | 17 +++++++++++++---- colophon.yml | 8 -------- docs/README.md | 17 +++++++++++------ src/index.js | 4 +++- src/lib/index.js | 7 ++----- src/lib/runs.js | 7 +++---- 10 files changed, 46 insertions(+), 71 deletions(-) delete mode 100644 .github/workflows/pull_request_target.yml delete mode 100644 .github/workflows/push.yml delete mode 100644 colophon.yml diff --git a/.env b/.env index e0df92c..021c269 100644 --- a/.env +++ b/.env @@ -1,6 +1,6 @@ GITHUB_EVENT_NAME=push GITHUB_EVENT_PATH=test/fixtures/payload.json -GITHUB_REPOSITORY=ahmadnassri/action-workflow-queue +GITHUB_REPOSITORY=durable-code/workflow-queue GITHUB_WORKSPACE=/github/workspace INPUT_GITHUB-TOKEN=$GITHUB_TOKEN diff --git a/.github/workflows/pull_request_target.yml b/.github/workflows/pull_request_target.yml deleted file mode 100644 index 3bc886c..0000000 --- a/.github/workflows/pull_request_target.yml +++ /dev/null @@ -1,14 +0,0 @@ -# ----------------------------------------------- # -# Note: this file originates in template-template # -# ----------------------------------------------- # - -name: pull_request_target - -on: pull_request_target - -permissions: read-all - -jobs: - main: - uses: ahmadnassri/actions/.github/workflows/pull-request-target.yml@master - secrets: inherit diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml deleted file mode 100644 index 245ec52..0000000 --- a/.github/workflows/push.yml +++ /dev/null @@ -1,21 +0,0 @@ -# ---------------------------------------------------- # -# Note: this file originates in template-action-docker # -# ---------------------------------------------------- # - -name: push - -on: - - push - - workflow_dispatch - -permissions: read-all - -jobs: - main: - uses: ahmadnassri/actions/.github/workflows/push-action-docker.yml@master - secrets: inherit - permissions: - contents: write - statuses: write - packages: write - pull-requests: write diff --git a/README.md b/README.md index 260f677..4fe572f 100644 --- a/README.md +++ b/README.md @@ -20,25 +20,31 @@ Workflows run on every commit asynchronously, this is fine for most cases, howev ###### `.github/workflows/my-workflow.yml` -``` yaml +```yaml jobs: xyz: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: ahmadnassri/action-workflow-queue@v1 + - uses: durable-code/workflow-queue + with: + workflow-ref: ${{ github.workflow_ref }} + run-id: ${{ github.run_id }} # only runs additional steps if there is no other instance of `my-workflow.yml` currently running ``` ### Inputs -| input | required | default | description | -|----------------|----------|----------------|-------------------------------------------------| -| `github-token` | ❌ | `github.token` | The GitHub token used to call the GitHub API | -| `timeout` | ❌ | `600000` | timeout before we stop trying (in milliseconds) | -| `delay` | ❌ | `10000` | delay between status checks (in milliseconds) | +| input | required | default | description | +| -------------- | -------- | -------------- | ------------------------------------------------------- | +| `github-token` | ❌ | `github.token` | The GitHub token used to call the GitHub API | +| `workflow-ref` | ✅ | - | The `${{ github.workflow_ref }}` of the caller workflow | +| `workflow-ref` | ✅ | - | The `${{ github.run_id }}` of the caller workflow | +| `timeout` | ❌ | `600000` | timeout before we stop trying (in milliseconds) | +| `delay` | ❌ | `10000` | delay between status checks (in milliseconds) | + ---- > Author: [Ahmad Nassri](https://www.ahmadnassri.com/) • diff --git a/action.yml b/action.yml index d146afe..918d9b9 100644 --- a/action.yml +++ b/action.yml @@ -1,15 +1,24 @@ name: Workflow Queue -description: If the same workflow is already running from a previous commit, wait for it to finish +description: if a given workflow is already running, that this action isn't running as a part of, then wait for it to finish + branding: - color: yellow + color: green icon: clock inputs: github-token: - description: The GitHub token used to post comments on pull requests + description: The GitHub token used to check running workflows. default: ${{ github.token }} + workflow-ref: + description: The GitHub workflow ref to queue on. + required: true + + run-id: + description: The run id of the caller workflow that this action is within. + required: true + timeout: description: timeout before we stop trying (in milliseconds) default: "600000" @@ -20,4 +29,4 @@ inputs: runs: using: docker - image: docker://ghcr.io/ahmadnassri/action-workflow-queue:1.2.0 + image: docker://ghcr.io/durable-code/workflow-queue:latest diff --git a/colophon.yml b/colophon.yml deleted file mode 100644 index 1eaed1f..0000000 --- a/colophon.yml +++ /dev/null @@ -1,8 +0,0 @@ -version: 2.0 - -id: action-workflow-queue - -about: - title: "GitHub Action: Workflow Run Queue" - description: If the same workflow is already running from a previous commit, wait for it to finish - repository: ahmadnassri/action-workflow-queue diff --git a/docs/README.md b/docs/README.md index 42d7dca..7b6ad80 100644 --- a/docs/README.md +++ b/docs/README.md @@ -20,15 +20,20 @@ jobs: steps: - uses: actions/checkout@v2 - - uses: ahmadnassri/action-workflow-queue@v1 + - uses: durable-code/workflow-queue + with: + workflow-ref: ${{ github.workflow_ref }} + run-id: ${{ github.run_id }} # only runs additional steps if there is no other instance of `my-workflow.yml` currently running ``` ### Inputs -| input | required | default | description | -| -------------- | -------- | -------------- | ----------------------------------------------- | -| `github-token` | ❌ | `github.token` | The GitHub token used to call the GitHub API | -| `timeout` | ❌ | `600000` | timeout before we stop trying (in milliseconds) | -| `delay` | ❌ | `10000` | delay between status checks (in milliseconds) | +| input | required | default | description | +| -------------- | -------- | -------------- | ------------------------------------------------------- | +| `github-token` | ❌ | `github.token` | The GitHub token used to call the GitHub API | +| `workflow-ref` | ✅ | - | The `${{ github.workflow_ref }}` of the caller workflow | +| `workflow-ref` | ✅ | - | The `${{ github.run_id }}` of the caller workflow | +| `timeout` | ❌ | `600000` | timeout before we stop trying (in milliseconds) | +| `delay` | ❌ | `10000` | delay between status checks (in milliseconds) | diff --git a/src/index.js b/src/index.js index 8a0eecc..e8479f6 100644 --- a/src/index.js +++ b/src/index.js @@ -9,7 +9,9 @@ import main from './lib/index.js' // parse inputs const inputs = { - token: core.getInput('github-token', { required: true }), + github_token: core.getInput('github-token', { required: true }), + workflow_ref: core.getInput('workflow-ref', { required: true }), + run_id: core.getInput('run-id', { required: true }), delay: Number(core.getInput('delay', { required: true })), timeout: Number(core.getInput('timeout', { required: true })) } diff --git a/src/lib/index.js b/src/lib/index.js index e1ec4af..846d9b0 100644 --- a/src/lib/index.js +++ b/src/lib/index.js @@ -10,15 +10,12 @@ import runs from './runs.js' // sleep function const sleep = ms => new Promise(resolve => setTimeout(resolve, ms)) -export default async function ({ token, delay, timeout }) { +export default async function ({ token, ref, run_id, delay, timeout }) { let timer = 0 // init octokit const octokit = github.getOctokit(token) - // extract runId - const { runId: run_id } = github.context - // get workflow id and created date from run id const { data: { workflow_id, run_started_at } } = await octokit.request('GET /repos/{owner}/{repo}/actions/runs/{run_id}', { ...github.context.repo, @@ -31,7 +28,7 @@ export default async function ({ token, delay, timeout }) { core.info(`searching for workflow runs before ${before}`) // get previous runs - let waiting_for = await runs({ octokit, run_id, workflow_id, before }) + let waiting_for = await runs({ octokit, run_id, workflow_ref, before }) if (waiting_for.length === 0) { core.info('no active run of this workflow found') diff --git a/src/lib/runs.js b/src/lib/runs.js index 6afc84a..50b4733 100644 --- a/src/lib/runs.js +++ b/src/lib/runs.js @@ -7,11 +7,10 @@ import { inspect } from 'util' import core from '@actions/core' import github from '@actions/github' -export default async function ({ octokit, workflow_id, run_id, before }) { +export default async function ({ octokit, run_id, workflow_ref, before }) { // get current run of this workflow - const { data: { workflow_runs } } = await octokit.request('GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}/runs', { - ...github.context.repo, - workflow_id + const { data: { workflow_runs } } = await octokit.request('GET /repos/{owner}/{repo}/actions/workflows/{workflow_ref}/runs', { + workflow_ref.replace(".github", "actions").split("@")[0], }) // find any instances of the same workflow From edcade3c65ac7545e3f5bd38bcc3c5de857fbfd1 Mon Sep 17 00:00:00 2001 From: liammcinroy <1899809+liammcinroy@users.noreply.github.com> Date: Thu, 28 Mar 2024 11:29:29 -0600 Subject: [PATCH 2/9] fix dockerfile --- Dockerfile | 12 ++++++------ README.md | 2 +- docs/README.md | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index f71229b..7c27464 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,12 +4,12 @@ FROM alpine:3.19 AS base # hadolint ignore=DL3018 RUN apk add --no-cache --update \ - nodejs=18.18.2-r0 \ - git=2.40.1-r0 \ - openssh=9.3_p2-r0 \ - ca-certificates=20230506-r0 \ + nodejs=20.11.1-r0 \ + git=2.43.0-r0 \ + openssh=9.6_p1-r0 \ + ca-certificates=20240226-r0 \ ruby-bundler=2.4.15-r0 \ - bash=5.2.15-r5 + bash=5.2.21-r0 WORKDIR /action @@ -18,7 +18,7 @@ WORKDIR /action FROM base AS build # hadolint ignore=DL3018 -RUN apk add --no-cache npm=9.6.6-r0 +RUN apk add --no-cache npm=10.2.5-r0 # slience npm # hadolint ignore=DL3059 diff --git a/README.md b/README.md index 4fe572f..bd67ec6 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ jobs: | -------------- | -------- | -------------- | ------------------------------------------------------- | | `github-token` | ❌ | `github.token` | The GitHub token used to call the GitHub API | | `workflow-ref` | ✅ | - | The `${{ github.workflow_ref }}` of the caller workflow | -| `workflow-ref` | ✅ | - | The `${{ github.run_id }}` of the caller workflow | +| `run-id` | ✅ | - | The `${{ github.run_id }}` of the caller workflow | | `timeout` | ❌ | `600000` | timeout before we stop trying (in milliseconds) | | `delay` | ❌ | `10000` | delay between status checks (in milliseconds) | diff --git a/docs/README.md b/docs/README.md index 7b6ad80..a7f2272 100644 --- a/docs/README.md +++ b/docs/README.md @@ -34,6 +34,6 @@ jobs: | -------------- | -------- | -------------- | ------------------------------------------------------- | | `github-token` | ❌ | `github.token` | The GitHub token used to call the GitHub API | | `workflow-ref` | ✅ | - | The `${{ github.workflow_ref }}` of the caller workflow | -| `workflow-ref` | ✅ | - | The `${{ github.run_id }}` of the caller workflow | +| `run-id` | ✅ | - | The `${{ github.run_id }}` of the caller workflow | | `timeout` | ❌ | `600000` | timeout before we stop trying (in milliseconds) | | `delay` | ❌ | `10000` | delay between status checks (in milliseconds) | From 246b6aca0d5a0fe5451c6e2bc8b80142671bc766 Mon Sep 17 00:00:00 2001 From: liammcinroy <1899809+liammcinroy@users.noreply.github.com> Date: Thu, 28 Mar 2024 11:49:53 -0600 Subject: [PATCH 3/9] update --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bd67ec6..3438c60 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # GitHub Action: Workflow Run Queue -If the same workflow is already running from a previous commit, wait for it to finish +if a given workflow is already running, that this action isn't running as a part of, then wait for it to finish [![license][license-img]][license-url] [![release][release-img]][release-url] From c1f5180137b4864789e9db0187e7c159d190b783 Mon Sep 17 00:00:00 2001 From: liammcinroy <1899809+liammcinroy@users.noreply.github.com> Date: Thu, 28 Mar 2024 12:49:48 -0600 Subject: [PATCH 4/9] fix --- src/lib/index.js | 2 +- src/lib/runs.js | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/lib/index.js b/src/lib/index.js index 846d9b0..b9c22de 100644 --- a/src/lib/index.js +++ b/src/lib/index.js @@ -28,7 +28,7 @@ export default async function ({ token, ref, run_id, delay, timeout }) { core.info(`searching for workflow runs before ${before}`) // get previous runs - let waiting_for = await runs({ octokit, run_id, workflow_ref, before }) + let waiting_for = await runs({ octokit, run_id, workflow_id, before }) if (waiting_for.length === 0) { core.info('no active run of this workflow found') diff --git a/src/lib/runs.js b/src/lib/runs.js index 50b4733..fd71756 100644 --- a/src/lib/runs.js +++ b/src/lib/runs.js @@ -7,10 +7,11 @@ import { inspect } from 'util' import core from '@actions/core' import github from '@actions/github' -export default async function ({ octokit, run_id, workflow_ref, before }) { +export default async function ({ octokit, run_id, workflow_id, before }) { // get current run of this workflow - const { data: { workflow_runs } } = await octokit.request('GET /repos/{owner}/{repo}/actions/workflows/{workflow_ref}/runs', { - workflow_ref.replace(".github", "actions").split("@")[0], + const { data: { workflow_runs } } = await octokit.request('GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}/runs', { + ...github.context.repo, + workflow_id }) // find any instances of the same workflow From 3188446de7fb0740f234b1b0810ba72dfce1945a Mon Sep 17 00:00:00 2001 From: liammcinroy <1899809+liammcinroy@users.noreply.github.com> Date: Thu, 28 Mar 2024 12:54:10 -0600 Subject: [PATCH 5/9] remove `workflow_ref` --- README.md | 2 -- action.yml | 4 ---- docs/README.md | 2 -- src/index.js | 1 - src/lib/index.js | 2 +- 5 files changed, 1 insertion(+), 10 deletions(-) diff --git a/README.md b/README.md index 3438c60..c2ddd2c 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,6 @@ jobs: - uses: actions/checkout@v2 - uses: durable-code/workflow-queue with: - workflow-ref: ${{ github.workflow_ref }} run-id: ${{ github.run_id }} # only runs additional steps if there is no other instance of `my-workflow.yml` currently running @@ -40,7 +39,6 @@ jobs: | input | required | default | description | | -------------- | -------- | -------------- | ------------------------------------------------------- | | `github-token` | ❌ | `github.token` | The GitHub token used to call the GitHub API | -| `workflow-ref` | ✅ | - | The `${{ github.workflow_ref }}` of the caller workflow | | `run-id` | ✅ | - | The `${{ github.run_id }}` of the caller workflow | | `timeout` | ❌ | `600000` | timeout before we stop trying (in milliseconds) | | `delay` | ❌ | `10000` | delay between status checks (in milliseconds) | diff --git a/action.yml b/action.yml index 918d9b9..ee02aab 100644 --- a/action.yml +++ b/action.yml @@ -11,10 +11,6 @@ inputs: description: The GitHub token used to check running workflows. default: ${{ github.token }} - workflow-ref: - description: The GitHub workflow ref to queue on. - required: true - run-id: description: The run id of the caller workflow that this action is within. required: true diff --git a/docs/README.md b/docs/README.md index a7f2272..ec5d36b 100644 --- a/docs/README.md +++ b/docs/README.md @@ -22,7 +22,6 @@ jobs: - uses: actions/checkout@v2 - uses: durable-code/workflow-queue with: - workflow-ref: ${{ github.workflow_ref }} run-id: ${{ github.run_id }} # only runs additional steps if there is no other instance of `my-workflow.yml` currently running @@ -33,7 +32,6 @@ jobs: | input | required | default | description | | -------------- | -------- | -------------- | ------------------------------------------------------- | | `github-token` | ❌ | `github.token` | The GitHub token used to call the GitHub API | -| `workflow-ref` | ✅ | - | The `${{ github.workflow_ref }}` of the caller workflow | | `run-id` | ✅ | - | The `${{ github.run_id }}` of the caller workflow | | `timeout` | ❌ | `600000` | timeout before we stop trying (in milliseconds) | | `delay` | ❌ | `10000` | delay between status checks (in milliseconds) | diff --git a/src/index.js b/src/index.js index e8479f6..252f120 100644 --- a/src/index.js +++ b/src/index.js @@ -10,7 +10,6 @@ import main from './lib/index.js' // parse inputs const inputs = { github_token: core.getInput('github-token', { required: true }), - workflow_ref: core.getInput('workflow-ref', { required: true }), run_id: core.getInput('run-id', { required: true }), delay: Number(core.getInput('delay', { required: true })), timeout: Number(core.getInput('timeout', { required: true })) diff --git a/src/lib/index.js b/src/lib/index.js index b9c22de..430045a 100644 --- a/src/lib/index.js +++ b/src/lib/index.js @@ -10,7 +10,7 @@ import runs from './runs.js' // sleep function const sleep = ms => new Promise(resolve => setTimeout(resolve, ms)) -export default async function ({ token, ref, run_id, delay, timeout }) { +export default async function ({ token, run_id, delay, timeout }) { let timer = 0 // init octokit From a2697128ab01688331908fdf0f92f90f160ec3a5 Mon Sep 17 00:00:00 2001 From: liammcinroy <1899809+liammcinroy@users.noreply.github.com> Date: Thu, 28 Mar 2024 13:02:09 -0600 Subject: [PATCH 6/9] add `github-token` as required --- README.md | 3 ++- action.yml | 2 +- docs/README.md | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c2ddd2c..2d10719 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ jobs: - uses: actions/checkout@v2 - uses: durable-code/workflow-queue with: + github-token: ${{ github.token }} run-id: ${{ github.run_id }} # only runs additional steps if there is no other instance of `my-workflow.yml` currently running @@ -38,7 +39,7 @@ jobs: | input | required | default | description | | -------------- | -------- | -------------- | ------------------------------------------------------- | -| `github-token` | ❌ | `github.token` | The GitHub token used to call the GitHub API | +| `github-token` | ✅ | - | The `${{ github.token }}` to call the GitHub API | | `run-id` | ✅ | - | The `${{ github.run_id }}` of the caller workflow | | `timeout` | ❌ | `600000` | timeout before we stop trying (in milliseconds) | | `delay` | ❌ | `10000` | delay between status checks (in milliseconds) | diff --git a/action.yml b/action.yml index ee02aab..2874372 100644 --- a/action.yml +++ b/action.yml @@ -9,7 +9,7 @@ branding: inputs: github-token: description: The GitHub token used to check running workflows. - default: ${{ github.token }} + required: true run-id: description: The run id of the caller workflow that this action is within. diff --git a/docs/README.md b/docs/README.md index ec5d36b..3a08da4 100644 --- a/docs/README.md +++ b/docs/README.md @@ -22,6 +22,7 @@ jobs: - uses: actions/checkout@v2 - uses: durable-code/workflow-queue with: + github-token: ${{ github.token }} run-id: ${{ github.run_id }} # only runs additional steps if there is no other instance of `my-workflow.yml` currently running @@ -31,7 +32,7 @@ jobs: | input | required | default | description | | -------------- | -------- | -------------- | ------------------------------------------------------- | -| `github-token` | ❌ | `github.token` | The GitHub token used to call the GitHub API | +| `github-token` | ✅ | - | The `${{ github.token }}` to call the GitHub API | | `run-id` | ✅ | - | The `${{ github.run_id }}` of the caller workflow | | `timeout` | ❌ | `600000` | timeout before we stop trying (in milliseconds) | | `delay` | ❌ | `10000` | delay between status checks (in milliseconds) | From 04f0805b4e00871feca72742f354b497aab47630 Mon Sep 17 00:00:00 2001 From: liammcinroy <1899809+liammcinroy@users.noreply.github.com> Date: Thu, 28 Mar 2024 13:14:03 -0600 Subject: [PATCH 7/9] =?UTF-8?q?=F0=9F=A4=A6=E2=80=8D=E2=99=82=EF=B8=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 3 +-- action.yml | 2 +- docs/README.md | 3 +-- src/index.js | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 2d10719..c2ddd2c 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,6 @@ jobs: - uses: actions/checkout@v2 - uses: durable-code/workflow-queue with: - github-token: ${{ github.token }} run-id: ${{ github.run_id }} # only runs additional steps if there is no other instance of `my-workflow.yml` currently running @@ -39,7 +38,7 @@ jobs: | input | required | default | description | | -------------- | -------- | -------------- | ------------------------------------------------------- | -| `github-token` | ✅ | - | The `${{ github.token }}` to call the GitHub API | +| `github-token` | ❌ | `github.token` | The GitHub token used to call the GitHub API | | `run-id` | ✅ | - | The `${{ github.run_id }}` of the caller workflow | | `timeout` | ❌ | `600000` | timeout before we stop trying (in milliseconds) | | `delay` | ❌ | `10000` | delay between status checks (in milliseconds) | diff --git a/action.yml b/action.yml index 2874372..ee02aab 100644 --- a/action.yml +++ b/action.yml @@ -9,7 +9,7 @@ branding: inputs: github-token: description: The GitHub token used to check running workflows. - required: true + default: ${{ github.token }} run-id: description: The run id of the caller workflow that this action is within. diff --git a/docs/README.md b/docs/README.md index 3a08da4..ec5d36b 100644 --- a/docs/README.md +++ b/docs/README.md @@ -22,7 +22,6 @@ jobs: - uses: actions/checkout@v2 - uses: durable-code/workflow-queue with: - github-token: ${{ github.token }} run-id: ${{ github.run_id }} # only runs additional steps if there is no other instance of `my-workflow.yml` currently running @@ -32,7 +31,7 @@ jobs: | input | required | default | description | | -------------- | -------- | -------------- | ------------------------------------------------------- | -| `github-token` | ✅ | - | The `${{ github.token }}` to call the GitHub API | +| `github-token` | ❌ | `github.token` | The GitHub token used to call the GitHub API | | `run-id` | ✅ | - | The `${{ github.run_id }}` of the caller workflow | | `timeout` | ❌ | `600000` | timeout before we stop trying (in milliseconds) | | `delay` | ❌ | `10000` | delay between status checks (in milliseconds) | diff --git a/src/index.js b/src/index.js index 252f120..079a702 100644 --- a/src/index.js +++ b/src/index.js @@ -9,7 +9,7 @@ import main from './lib/index.js' // parse inputs const inputs = { - github_token: core.getInput('github-token', { required: true }), + token: core.getInput('github-token', { required: true }), run_id: core.getInput('run-id', { required: true }), delay: Number(core.getInput('delay', { required: true })), timeout: Number(core.getInput('timeout', { required: true })) From 40f4f27601052b01ac6e5a2de83f7c1dd618f0bd Mon Sep 17 00:00:00 2001 From: liammcinroy <1899809+liammcinroy@users.noreply.github.com> Date: Thu, 28 Mar 2024 13:29:13 -0600 Subject: [PATCH 8/9] add permissions docs --- README.md | 3 +++ docs/README.md | 3 +++ 2 files changed, 6 insertions(+) diff --git a/README.md b/README.md index c2ddd2c..8bb38ae 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,9 @@ jobs: xyz: runs-on: ubuntu-latest + permissions: + actions: read + steps: - uses: actions/checkout@v2 - uses: durable-code/workflow-queue diff --git a/docs/README.md b/docs/README.md index ec5d36b..65aaa0c 100644 --- a/docs/README.md +++ b/docs/README.md @@ -18,6 +18,9 @@ jobs: xyz: runs-on: ubuntu-latest + permissions: + actions: read + steps: - uses: actions/checkout@v2 - uses: durable-code/workflow-queue From ea3906c7757b124e8e927b25e2d73b87f79dd7b4 Mon Sep 17 00:00:00 2001 From: liammcinroy <1899809+liammcinroy@users.noreply.github.com> Date: Thu, 28 Mar 2024 14:12:36 -0600 Subject: [PATCH 9/9] updates + fix "minutes" vs "seconds" --- .github/FUNDING.yml | 5 ----- README.md | 3 +++ docs/README.md | 40 ---------------------------------------- docs/README.template | 18 ------------------ package.json | 11 +++++------ src/lib/index.js | 2 +- 6 files changed, 9 insertions(+), 70 deletions(-) delete mode 100644 .github/FUNDING.yml delete mode 100644 docs/README.md delete mode 100644 docs/README.template diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml deleted file mode 100644 index c244427..0000000 --- a/.github/FUNDING.yml +++ /dev/null @@ -1,5 +0,0 @@ -# ----------------------------------------------- # -# Note: this file originates in template-template # -# ----------------------------------------------- # - -github: [ahmadnassri] diff --git a/README.md b/README.md index 8bb38ae..b841b2c 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,9 @@ jobs: ---- + +Adapted from https://github.com/ahmadnassri/action-workflow-queue + > Author: [Ahmad Nassri](https://www.ahmadnassri.com/) • > Twitter: [@AhmadNassri](https://twitter.com/AhmadNassri) diff --git a/docs/README.md b/docs/README.md deleted file mode 100644 index 65aaa0c..0000000 --- a/docs/README.md +++ /dev/null @@ -1,40 +0,0 @@ - -
- Why? - - Workflows run on every commit asynchronously, this is fine for most cases, however, you might want to wait for a previous commit workflow to finish before running another one, some example use-cases: - - - Deployment workflows - - Terraform workflows - - Database Migrations -
- -## Usage - -###### `.github/workflows/my-workflow.yml` - -```yaml -jobs: - xyz: - runs-on: ubuntu-latest - - permissions: - actions: read - - steps: - - uses: actions/checkout@v2 - - uses: durable-code/workflow-queue - with: - run-id: ${{ github.run_id }} - - # only runs additional steps if there is no other instance of `my-workflow.yml` currently running -``` - -### Inputs - -| input | required | default | description | -| -------------- | -------- | -------------- | ------------------------------------------------------- | -| `github-token` | ❌ | `github.token` | The GitHub token used to call the GitHub API | -| `run-id` | ✅ | - | The `${{ github.run_id }}` of the caller workflow | -| `timeout` | ❌ | `600000` | timeout before we stop trying (in milliseconds) | -| `delay` | ❌ | `10000` | delay between status checks (in milliseconds) | diff --git a/docs/README.template b/docs/README.template deleted file mode 100644 index fed76c1..0000000 --- a/docs/README.template +++ /dev/null @@ -1,18 +0,0 @@ -# $about.title$ - -$about.description$ - -[![license][license-img]][license-url] -[![release][release-img]][release-url] - -$body$ - ----- -> Author: [Ahmad Nassri](https://www.ahmadnassri.com/) • -> Twitter: [@AhmadNassri](https://twitter.com/AhmadNassri) - -[license-url]: LICENSE -[license-img]: https://badgen.net/github/license/$about.repository$ - -[release-url]: https://github.com/$about.repository$/releases -[release-img]: https://badgen.net/github/release/$about.repository$ diff --git a/package.json b/package.json index f4064d6..3d13410 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,11 @@ { "private": true, - "name": "actions-workflow-queue", - "version": "0.0.0-semantically-released", - "description": "wait for all `workflow_run` required workflows to be successful", + "name": "workflow-queue", + "version": "1.4.0", + "description": "if a given workflow is already running, that this action isn't running as a part of, then wait for it to finish", "author": { - "name": "Ahmad Nassri", - "email": "ahmad@ahmadnassri.com", - "url": "https://ahmadnassri.com" + "name": "Liam McInroy", + "email": "liam@durable.ai" }, "scripts": { "test": "echo nothing to test && exit 0", diff --git a/src/lib/index.js b/src/lib/index.js index 430045a..c12dd2d 100644 --- a/src/lib/index.js +++ b/src/lib/index.js @@ -50,7 +50,7 @@ export default async function ({ token, run_id, delay, timeout }) { } // zzz - core.info(`waiting for #${delay/1000} minutes before polling the status again`) + core.info(`waiting for #${delay/1000} seconds before polling the status again`) await sleep(delay) // get the data again