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 CI | GitHub Actions |
|---|---|
cache.key | actions/cache key |
cache.paths | actions/cache path |
cache: pull / push policy | restore-only vs full cache step |
artifacts.paths | upload-artifact path |
| automatic stage artifact passing | explicit download-artifact |
Before
.gitlab-ci.yml
build:
cache:
key: ${CI_COMMIT_REF_SLUG}
paths: [node_modules/]
artifacts:
paths: [dist/]
script:
- npm ci
- npm run buildAfter
.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_SLUGcaches 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
How to Migrate From GitLab CI to GitHub ActionsConvert a .gitlab-ci.yml to GitHub Actions, mapping stages to jobs with needs, script to run, artifacts to up…
How to Migrate Cache Config to GitHub ActionsTranslate cache keys and paths from Travis, CircleCI, GitLab, or Bitbucket into GitHub Actions using actions/…