Skip to content
Latchkey

How to Migrate GitLab CI Cache and Artifacts to GitHub Actions

GitLab cache maps to actions/cache with an explicit key, and artifacts map to upload-artifact in the producer plus download-artifact in the consumer.

GitLab cache restores a keyed directory; the Actions equivalent is actions/cache with a key and restore-keys. GitLab artifacts flow automatically; in Actions you upload then download by name.

Concept mapping

GitLab CIGitHub Actions
cache.keyactions/cache key
cache.pathsactions/cache path
cache: pull / push policyrestore-only vs full cache step
artifacts.pathsupload-artifact path
automatic stage artifact passingexplicit download-artifact

Before

.gitlab-ci.yml
build:
  cache:
    key: ${CI_COMMIT_REF_SLUG}
    paths: [node_modules/]
  artifacts:
    paths: [dist/]
  script:
    - npm ci
    - npm run build

After

.github/workflows/ci.yml
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/cache@v4
        with:
          path: node_modules
          key: npm-${{ hashFiles('package-lock.json') }}
          restore-keys: npm-
      - run: npm ci && npm run build
      - uses: actions/upload-artifact@v4
        with: { name: dist, path: dist/ }

What does not map cleanly

  • A branch-slug cache key like CI_COMMIT_REF_SLUG caches per branch; prefer a lockfile hash so restores hit more often.
  • GitLab artifacts have an expiry and can be browsed in the UI; Actions artifacts have a retention setting and are downloaded as zips.
  • GitLab cache policies (pull only) map to a restore step without a save, not a single keyword.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →