github-action-locks
github-action-locks copied to clipboard
Lock is not released when lock name is passed through internal action and it is concated with input.
Example
name: Feature Pull Requests and merged PR.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
pull_request:
branches: [master]
workflow_dispatch:
jobs:
Test-run-lock:
runs-on: [ label ]
steps:
- name: Checkout source code
uses: actions/checkout@v2
- name: Create a lock.
uses: ./.github/actions/extra-middle-action
with:
lock-key-name: lurbanski6
extra-middle-action/action.yaml
name: extra-middle-action
description: test
inputs:
lock-key-name:
required: false
description: Lock key name.
default: ${{ github.workflow }}
runs:
using: composite
steps:
- name: Create a lock.
uses: ./.github/actions/create-lock-action
with:
lock-key-name: prefix-${{ inputs.lock-key-name }} #doesn't work
# lock-key-name: ${{ inputs.lock-key-name }} #It works. Without prefix/suffix
# lock-key-name: "prefix-${{ inputs.lock-key-name }}" # I tried with single quote, double and concating prefix with lock-key-name using https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable. All solutions doesn't work.
create-lock-action/action.yaml
name: Create a lock
description: Create a lock.
inputs:
lock-key-name:
required: false
description: Lock key name.
default: ${{ github.workflow }}
runs:
using: composite
steps:
# aws-actions/configure-aws-credentials@v1 etc
- name: Create a lock
uses: abatilo/github-action-locks@v1
with:
timeout: "30"
table: "iam_runners_lock"
key: "LockID"
name: 'RepositoryPrefix-${{ inputs.lock-key-name }}'
If there is prefix or suffix in the extra-middle-action. The lock is not released. btw, the lock name in logs looks ok.
Update: After testing my conclusions are that.
- It works when extra-middle-action only passes ${{ inputs.lock-key-name }} without changes.
- It doesn't work when extra-middle-action only passes plain string e.g. "123" or concat string with input e.g. "prefix-${{ inputs.lock-key-name }}"