Skip to content

Commit

Permalink
Use github.token by default (#5)
Browse files Browse the repository at this point in the history
* Test github.token

* Use default token

* Update README
  • Loading branch information
ben-z authored Mar 29, 2022
1 parent a6ddff2 commit fadfe15
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ jobs:
- uses: actions/checkout@v3
- name: Set up mutex
uses: ./
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- run: |
echo "I am protected!"
sleep 5
Expand All @@ -24,7 +22,6 @@ jobs:
uses: ./
with:
branch: gh-mutex-two-clients-test
repo-token: ${{ secrets.GITHUB_TOKEN }}
- run: |
echo "I am protected! (Client 1)"
sleep 20
Expand All @@ -39,7 +36,6 @@ jobs:
uses: ./
with:
branch: gh-mutex-two-clients-test
repo-token: ${{ secrets.GITHUB_TOKEN }}
- run: |
echo "I am protected! (Client 2)"
sleep 20
Expand All @@ -53,7 +49,6 @@ jobs:
- name: Set up mutex
uses: ./
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
debug: "true"
- run: |
echo "I am protected!"
Expand Down
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Set up mutex
uses: ben-z/[email protected]
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
uses: ben-z/[email protected]
- run: |
echo "I am protected!"
sleep 5
Expand All @@ -35,15 +33,16 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Set up mutex
uses: ben-z/[email protected]3
uses: ben-z/[email protected]4
with:
branch: another-mutex
repo-token: ${{ secrets.GITHUB_TOKEN }}
- run: |
echo "I am protected by the 'another-mutex' mutex!"
sleep 5
```

More options such as using a different repo to store the mutex (which allows sharing a mutex between jobs from arbitrary repos) or using different access tokens can be found in [actions.yml](./actions.yml)

## Motivation

GitHub Action has the [concurrency](https://docs.github.com/en/actions/using-jobs/using-concurrency) option for preventing running multiple jobs concurrently. However, it has a queue of length 1. When there are multiple jobs with the same concurrency group gets queued, only the currently running job and the latest job are kept. Other jobs are simply cancelled. There's more discussion [here](https://github.com/github/feedback/discussions/5435) and it appears that GitHub does not want to add the requested `cancel-pending` feature any time soon (as of 2022-03-26). This GitHub action solves that issue.
Expand Down
3 changes: 2 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ description: 'A simple locking/unlocking mechanism to provide mutual exclusion i
inputs:
repo-token:
description: 'The token for accessing the repo.'
required: true
required: false
default: ${{ github.token }}
repository:
description: 'The repository path that stores the lock. E.g `ben-z/gh-action-mutex`'
required: false
Expand Down

0 comments on commit fadfe15

Please sign in to comment.