🔧 AI Nachrichten The Next Terrorist Attack Is Predictable(10.09.2026 um 23:41 Uhr)
🔧 AI Nachrichten Could A.I. Really Kill All Humans?(10.09.2026 um 23:53 Uhr)
🔧 AI Nachrichten Amazon Prime Video Uses A.I. for Lip-Synced Translations(11.09.2026 um 01:56 Uhr)
🔧 AI Nachrichten McClatchy Makes Deep Job Cuts to Newspapers Around the Country(11.09.2026 um 04:25 Uhr)
🔧 AI Nachrichten Law schools tell students to put AI away(07.09.2026 um 16:37 Uhr)
🔧 AI Nachrichten Can Huawei build China’s answer to ASML?(08.09.2026 um 04:57 Uhr)
🔧 AI Nachrichten AI is ushering in an era of mass toe-treading at work(08.09.2026 um 06:00 Uhr)
🔧 AI Nachrichten The Next Terrorist Attack Is Predictable(10.09.2026 um 23:41 Uhr)
🔧 AI Nachrichten Could A.I. Really Kill All Humans?(10.09.2026 um 23:53 Uhr)
🔧 AI Nachrichten Amazon Prime Video Uses A.I. for Lip-Synced Translations(11.09.2026 um 01:56 Uhr)
🔧 AI Nachrichten McClatchy Makes Deep Job Cuts to Newspapers Around the Country(11.09.2026 um 04:25 Uhr)
🔧 AI Nachrichten Law schools tell students to put AI away(07.09.2026 um 16:37 Uhr)
🔧 AI Nachrichten Can Huawei build China’s answer to ASML?(08.09.2026 um 04:57 Uhr)
🔧 AI Nachrichten AI is ushering in an era of mass toe-treading at work(08.09.2026 um 06:00 Uhr)

🔧 Programmierung 🕛 vor 1 Jahr 3 Min Lesezeit
0

Lock Mechanism on GitHub Actions

↗ Quelle (dev.to)
🗣️ Stimme:
📑 Inhaltsübersicht

Sometimes, a lock mechanism is useful in CI workflows, like when you need to prevent simultaneous deployments or block deployments during maintenance.

In this post, I’ll introduce a GitHub Action for implementing a lock mechanism.





  • Records lock and unlock histories

  • Supports waiting until a lock is released





  • How to Use



    This action requires two inputs: key and mode.





    • key: an explicit identifier for the lock, which you can adjust by service and environment.


    • mode: the action’s operational mode, which can be one of these:



      • lock: Acquires a lock


      • unlock: Releases a lock


      • check: Checks the lock status





    mode: lock:




    CODE
    steps:
    - name: Acquire a lock for a key `foo` before deploying an application
    uses: suzuki-shunsuke/lock-action@latest
    with:
    mode: lock
    key: foo
    - run: bash deploy.sh foo






    mode: unlock:




    CODE
    steps:
    - name: Release a lock
    uses: suzuki-shunsuke/lock-action@latest
    with:
    mode: unlock
    key: foo






    mode: check:




    CODE
    steps:
    - name: Check if a key is being locked
    id: check
    uses: suzuki-shunsuke/lock-action@latest
    with:
    mode: check
    key: foo
    - run: bash deploy.sh foo
    if: steps.check.outputs.already_locked != 'true'






    You can also use post_unlock: "true" to release a lock automatically in a post step.




    CODE
      - uses: suzuki-shunsuke/lock-action@latest
    with:
    mode: lock
    key: foo
    post_unlock: "true"






    By default, mode: lock will fail if the key is already locked.

    Set ignore_already_locked_error: "true" to avoid this.




    CODE
    - uses: suzuki-shunsuke/lock-action@latest
    with:
    key: foo
    mode: lock
    ignore_already_locked_error: "true"






    To force mode: check to fail if a key is locked, use fail_if_locked: "true".




    CODE
    # This step fails if the key `foo` is being locked.
    - uses: suzuki-shunsuke/lock-action@latest
    with:
    mode: check
    key: foo
    fail_if_locked: "true"






    To wait until a lock is released, use max_wait_seconds and wait_interval_seconds.




    CODE
    - uses: suzuki-shunsuke/lock-action@latest
    with:
    mode: lock
    key: default
    # Try to acquire a lock every 10 seconds until acquiring a lock or 60 seconds pass.
    max_wait_seconds: "60"
    wait_interval_seconds: "10"






    These inputs are also available for mode: check.




    CODE
    - uses: suzuki-shunsuke/lock-action@latest
    with:
    mode: check
    key: default
    # Check a lock every 5 seconds until the lock is released or 60 seconds pass
    max_wait_seconds: "30"
    wait_interval_seconds: "5"









    How It Works



    This action manages locks by creating and updating GitHub branches.

    Each lock’s state is tracked in the commit message of a branch named ${{inputs.key_prefix}}${{inputs.key}} (default prefix: lock__, which can be customized with key_prefix).



    Commit message format:




    CODE
    unlock by suzuki-shunsuke: test
    {
    "message": "test",
    "state": "unlock",
    "actor": "suzuki-shunsuke",
    "github_actions_workflow_run_url": "https://github.com/suzuki-shunsuke/test-github-action/actions/runs/11545637203?pr=237",
    "pull_request_number": 237
    }






    From these commit messages, you can see when and who (actor, workflow run, pull request number) acquired or released the lock.





    Example links:










    Conclusion



    In this post, I introduced my GitHub Action for a lock mechanism. For more details, please visit the repository:



    https://github.com/suzuki-shunsuke/lock-action

    Vollständiger Original-Bericht
    Ausführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
    ↗ Original-Artikel auf dev.to lesen
    Wie bewertest du diesen Beitrag?
    1 Klick Feedback
    Teilen mit Netzwerk & Team:

    Community-Analysen & Experten-Meinungen 0

    Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
    Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
    Community Pulse: Relevanz-Einschätzung
    1 Klick Experten-Votum
    🔴 Akute Relevanz 0%
    🟡 In Evaluierung 0%
    🟢 Keine Auswirkung 0%
    Spannende Innovation 0%
    Verwandte Story-Cluster & Quellen (Vektor-KI)
    Port 8095 Engine
    2 Quellen
    Could A.I. Really Kill All Humans?
    1 Quelle
    The Next Terrorist Attack Is Predictable
    1 Quelle
    Anthropic Says It Blocked Possible Efforts to Build Biological Weapons
    Ähnliche Beiträge
    🔍 Verwandte News

    Auch interessante Nachrichten Lock Mechanism on GitHub Actions

    Thematisch verwandte Begriffe: Lock, Mechanism, GitHub, Actions · 6 Treffer

    Laden...

    Videos werden geladen ...

    Laden...

    Beiträge werden geladen ...

    Laden...

    Videos werden geladen ...

    Laden...

    Beiträge werden geladen ...

    Laden...

    Videos werden geladen ...

    Laden...

    Beiträge werden geladen ...

    Laden...

    Videos werden geladen ...

    Laden...

    Beiträge werden geladen ...

    Laden...

    Videos werden geladen ...