Skip to content

Add a GitHub Actions lockfile #80

Backlog

Description

@robin-simular

GitHub Actions now supports workflow lockfiles. A lockfile pins every action the workflows run to an exact commit, including the actions those actions use. That protects against supply chain attacks, for example through a transitive dependency whose tag is moved to malicious code.

The workflows here have no lockfile yet. I only have read access to this repo, so I can't open the PR. The change is small:

  1. Generate the lockfile and commit .github/workflows/actions.lock together with the uses: lines the tool rewrites. A dry run on main needed no extra flags.

    gh extension install github/gh-actions-lock
    gh actions-lock
  2. Add .github/workflows/verify-lockfile.yml, which fails when the lockfile and the workflows are out of sync. Run gh actions-lock again afterwards so this workflow is locked too.

    name: Verify actions lockfile
    
    on:
      pull_request:
        paths:
          - .github/**
      push:
        branches:
          - main
        paths:
          - .github/**
    
    permissions:
      contents: read
    
    jobs:
      verify:
        runs-on: ubuntu-latest
        steps:
          - uses: actions/checkout@v7.0.1
            with:
              persist-credentials: false
          - uses: github/gh-actions-lock@verify/v0.5.1
  3. Let Dependabot update the actions. It updates the lockfile in the same PR. Add .github/dependabot.yml:

    version: 2
    updates:
      - package-ecosystem: github-actions
        directory: /
        schedule:
          interval: weekly
        cooldown:
          default-days: 7

simular-ai/simulang#28 is an example of the finished change.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions