1
0
mirror of synced 2026-01-25 18:03:26 -05:00
Files
docs/content/actions/learn-github-actions/migrating-from-gitlab-cicd-to-github-actions.md
Matt Pollard 2db9da5c8f [DO NOT MERGE] GitHub AE consumables beta megabranch (#17620)
* Empty commit

* updated beta note for GHAE

* more GHAE update + resolve conflict

* more GHAE updates + prepare for screenshots

* Apply suggestions from code review

Co-authored-by: Shati Patel <42641846+shati-patel@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Shati Patel <42641846+shati-patel@users.noreply.github.com>

* address remaining review comments

* Revise "About GitHub AE" (#17679)

* add screenshots to the Configuring article

* reworked to have a separate GHAE section

* list numbering

* more work on screenshots and conditions

* add GHAE screenshots in article

* review screenshots in article

* added more screenshots and updated more articles

* screenshot madness

* fix liquid versioning

* refactor the ghae script

* [GHAE CB/Feb 22]: Add article about data residency for GitHub AE (#17847)

* add missing GHAE versioning to article

* move screenshots to GHAE asset directory

* forgot to change the path for these two images

* replace CBB screenshot + add better screenshot

* [GHAE CB/Feb 22]: Document upgrades for GitHub AE (#17848)

* Version article for GitHub AE

* Replace unused variable

* Incorporate reviewer feedback

* Update intro

Co-authored-by: Ethan P <56270045+ethanpalm@users.noreply.github.com>

* [GHAE] Enable IP allow list (#17691)

* Notes for CC

* Updat permission leves chart

* Add updated article to further reading

* Update gated feature callout with GitHub AE

* Version "Managing allowed IP addresses for your organization" for AE

* Update images

* Update "Restricting network traffic to your enterprise" with new procedures

* remove todo note

* Update audited actions

* Update info about Premium Runners

* Use reusable for Premium Runners

* Change "Premium Runners" to "AE hosted runners"

* Incorporate reviewer feedback

* Use correct reusable

* Version reusable correctly

* [Feb 22] GHAE: Code scanning beta (#17830)

* Add "github-ae" to all the frontmatter

* GHAE-ify the reusables

* Add some more changes

* Re-use some content

* 🔪 Semmle links

* Revert change re "--external-repository-token" in the CodeQL runner

* Update CodeQL runner token scopes

* Update two screenshots

* Remove mention of GitHub.com from AE + other fixes

* Apply suggestions from code review

Co-authored-by: mc <42146119+mchammer01@users.noreply.github.com>

* Use `product_name` variable instead of `product_location`

* Remove confusing phrase

* [Feb 22] GHAE: Code scanning API and webhook docs (#17883)

* Version API and webhook docs

* Actually add versioning for GHAE

* Fix anchor

* [TEMPORARY] Preview for API endpoints

* Revert API previews

* Update procedure step

Co-authored-by: mc <42146119+mchammer01@users.noreply.github.com>

* Update docs for AzureAD Group SCIM support in GHAE (#17892)

* [GHAE CB] SMTP bootstrapping flow (#17888)

* draft

* update with AE conntent

* update with tons of versioning

* remove that  lie

* fill out the rest of these steps

* update with correct versioning

* more edits

* add images

* reversion most of ae article

* fix versioning

* format correctlly

* words matter

* last image

* update with permmissions

* update versioning

* add link

* apply feedback ❤️

* update with differrent spacing

* update with feedback

* more feedback

* Temporary GHAE release notes for consumables beta launch (#17859)

* Create release-notes.md

* Add frontmatter

* Add to index file

* Update github-ae-release-notes.md

* Add release notes from Google Doc

* Update finalized docs links that have been reviewed

* OAuth device flow link update

* version for AE

* few fixes

* Update content/admin/overview/github-ae-release-notes.md

* small edits

* whoops

* commit

* update with different links

* used wrong reusable

* fix more brokenness

* Update repository-references.js

* Update repository-references.js

Co-authored-by: Meg Bird <megbird@github.com>
Co-authored-by: Kevin Heis <heiskr@users.noreply.github.com>

* [GHAE] Audit public repos (#17917)

* verifying what we mean by public

* Apply suggestions from code review

* Update content/developers/apps/installing-github-apps.md

Co-authored-by: Laura Coursen <lecoursen@github.com>

* fixing placememnt of liquid conditional

Co-authored-by: Laura Coursen <lecoursen@github.com>

* GHAE packages beta (#17786)

Co-authored-by: jmarlena <6732600+jmarlena@users.noreply.github.com>
Co-authored-by: Martin Lopes <martin389@github.com>

* fix broken links

* [GHAE CB/March 01]: GitHub Actions on GHAE (beta) (#17725)

* Added initial layout for premium runners

* Restructured content

* Added placeholder for removing premium runner

* Added versioning and warning note for self-hosted runners

* Added versioning and beta notice for actions content

* Rephrased beta note

* Added versioning for API docs, fixes

* Added versioning fixes

* Split Github-hosted and premium topics into separate articles

* Added edits

* Restructured some topics

* Revised "Using premium runners in a workflow"

* Some small fixes

* Fixed typo

* Added fixes to reusable

* Added edits

* Made section titles consistent

* Added billing, group mgmt, reusable steps

* Cropped certain screenshots for future-proofing

* Removed superfluous reusable

* Added fixes

* Revert "Cropped certain screenshots for future-proofing"

This reverts commit c7f24f31fa30d4fe3de2b63fc3cd5feba44ef518.

* Added new section for custom images

* Added versioning for enterprise-admin operations

* Added edits

* Added edits

* Update adding-premium-runners.md

* Removed SHR screenshots. Intending to update them when UI is available.

* Update using-labels-with-premium-runners.md

* Added custom labels section

* Added preview of API docs changes

* Added versioning for ip allow list section

* Removed removal article

* Renamed premium runners to AE hosted runners

* Re-added added API preview

* Fixed links, updated software specs

* Revised "Software specifications" based on feedback

* Fixed typos

* Small fixes

* Added new article "Creating custom images"

* Moved "Creating custom images" link

* Apply suggestions from code review

Co-authored-by: ahdbilal <55514721+ahdbilal@users.noreply.github.com>

* Added update from review

* Added updates from tech review

* Apply suggestions from code review

Co-authored-by: ahdbilal <55514721+ahdbilal@users.noreply.github.com>

* Added updates from tech review

* Added updates from tech review

* Added updates from tech review

* Added updates from tech review

* Fixed reusable

* Added fixes

* Added update from tech review

* Removed the dereferenced OpenAPI schema files

* Added fixes

* Fixed links

* Fixed links

* Apply suggestions from code review

Co-authored-by: jmarlena <6732600+jmarlena@users.noreply.github.com>

* Added updates from peer review

* Removed sections that are not in beta

* Update viewing-your-github-actions-usage.md

* Update viewing-job-execution-time.md

* Update index.md

* Update about-github-hosted-runners.md

* Restored versioning to match GHES approach

* Fixed link

* Restored self-hosted runner reference to UI steps.

* Updated screenshots

* Updated screenshots and procedures

* Small edits to screenshots

* Added AE url info for SHR

* Removed superfluous versioning

* Update security-hardening-for-github-actions.md

* Update actions-shared.md

* Small edits

* Update usage-limits-billing-and-administration.md

* Update managing-complex-workflows.md

* Additional versioning

* Additional versioning

* version environments api and checkrun deployments for ghae (#17991)

Co-authored-by: Martin Lopes <martin389@github.com>

* Update reviewing-the-audit-log-for-your-organization.md

* Added versioning for enterprise policy settings

* version configuring artifact retention for AE

* remove AE versioning for connecting to Marketplace

* Apply suggestions from code review

Co-authored-by: Joe Bourne <thejoebourneidentity@github.com>

* Update content/admin/github-actions/getting-started-with-github-actions-for-github-ae.md

Co-authored-by: Joe Bourne <thejoebourneidentity@github.com>

* rewording not public to private

* fixing liquid

* Fixed elseif entries

* Added expectations note

* Revised label management article for AE hosted runners

* Added enterprise-admin note for adding AE hosted runners

* Update enterprise-admin.md

* Update self-hosted-runner-security.md

* Versioned reusable for AE

* Empty commit for CI

Co-authored-by: ahdbilal <55514721+ahdbilal@users.noreply.github.com>
Co-authored-by: jmarlena <6732600+jmarlena@users.noreply.github.com>
Co-authored-by: skedwards88 <skedwards88@github.com>
Co-authored-by: Leona B. Campbell <3880403+runleonarun@users.noreply.github.com>
Co-authored-by: Joe Bourne <thejoebourneidentity@github.com>
Co-authored-by: runleonarun <runleonarun@github.com>

* Update OpenAPI Descriptions for GHAE

* Update content/admin/overview/github-ae-release-notes.md

Co-authored-by: Ethan Palm <56270045+ethanpalm@users.noreply.github.com>
Co-authored-by: mchammer01 <42146119+mchammer01@users.noreply.github.com>
Co-authored-by: Shati Patel <42641846+shati-patel@users.noreply.github.com>
Co-authored-by: shati-patel <shati-patel@github.com>
Co-authored-by: Sarah Schneider <sarahs@github.com>
Co-authored-by: skedwards88 <skedwards88@github.com>
Co-authored-by: Sarah Schneider <sarahs@users.noreply.github.com>
Co-authored-by: Melanie Yarbrough <11952755+myarb@users.noreply.github.com>
Co-authored-by: Felicity Chapman <felicitymay@github.com>
Co-authored-by: Meg Bird <megbird@github.com>
Co-authored-by: Kevin Heis <heiskr@users.noreply.github.com>
Co-authored-by: Leona B. Campbell <3880403+runleonarun@users.noreply.github.com>
Co-authored-by: Laura Coursen <lecoursen@github.com>
Co-authored-by: jmarlena <6732600+jmarlena@users.noreply.github.com>
Co-authored-by: Martin Lopes <martin389@github.com>
Co-authored-by: ahdbilal <55514721+ahdbilal@users.noreply.github.com>
Co-authored-by: Joe Bourne <thejoebourneidentity@github.com>
Co-authored-by: runleonarun <runleonarun@github.com>
Co-authored-by: github-openapi-bot <69533958+github-openapi-bot@users.noreply.github.com>
2021-03-01 16:07:02 -05:00

485 lines
13 KiB
Markdown

---
title: Migrating from GitLab CI/CD to GitHub Actions
intro: '{% data variables.product.prodname_actions %} and GitLab CI/CD share several configuration similarities, which makes migrating to {% data variables.product.prodname_actions %} relatively straightforward.'
versions:
free-pro-team: '*'
enterprise-server: '>=2.22'
github-ae: '*'
type: 'tutorial'
topics:
- 'GitLab'
- 'Migration'
- 'CI'
- 'CD'
---
{% data reusables.actions.enterprise-beta %}
{% data reusables.actions.enterprise-github-hosted-runners %}
{% data reusables.actions.ae-beta %}
### Introduction
GitLab CI/CD and {% data variables.product.prodname_actions %} both allow you to create workflows that automatically build, test, publish, release, and deploy code. GitLab CI/CD and {% data variables.product.prodname_actions %} share some similarities in workflow configuration:
- Workflow configuration files are written in YAML and are stored in the code's repository.
- Workflows include one or more jobs.
- Jobs include one or more steps or individual commands.
- Jobs can run on either managed or self-hosted machines.
There are a few differences, and this guide will show you the important differences so that you can migrate your workflow to {% data variables.product.prodname_actions %}.
### Jobs
Jobs in GitLab CI/CD are very similar to jobs in {% data variables.product.prodname_actions %}. In both systems, jobs have the following characteristics:
* Jobs contain a series of steps or scripts that run sequentially.
* Jobs can run on separate machines or in separate containers.
* Jobs run in parallel by default, but can be configured to run sequentially.
You can run a script or a shell command in a job. In GitLab CI/CD, script steps are specified using the `script` key. In {% data variables.product.prodname_actions %}, all scripts are specified using the `run` key.
Below is an example of the syntax for each system:
<table class="d-block">
<tr>
<th>
GitLab CI/CD
</th>
<th>
{% data variables.product.prodname_actions %}
</th>
</tr>
<tr>
<td class="d-table-cell v-align-top">
{% raw %}
```yaml
job1:
variables:
GIT_CHECKOUT: "true"
script:
- echo "Run your script here"
```
{% endraw %}
</td>
<td class="d-table-cell v-align-top">
{% raw %}
```yaml
jobs:
job1:
steps:
- uses: actions/checkout@v2
- run: echo "Run your script here"
```
{% endraw %}
</td>
</tr>
</table>
### Runners
Runners are machines on which the jobs run. Both GitLab CI/CD and {% data variables.product.prodname_actions %} offer managed and self-hosted variants of runners. In GitLab CI/CD, `tags` are used to run jobs on different platforms, while in {% data variables.product.prodname_actions %} it is done with the `runs-on` key.
Below is an example of the syntax for each system:
<table>
<tr>
<th>
GitLab CI/CD
</th>
<th>
{% data variables.product.prodname_actions %}
</th>
</tr>
<tr>
<td class="d-table-cell v-align-top">
{% raw %}
```yaml
windows_job:
tags:
- windows
script:
- echo Hello, %USERNAME%!
linux_job:
tags:
- linux
script:
- echo "Hello, $USER!"
```
{% endraw %}
</td>
<td class="d-table-cell v-align-top">
{% raw %}
```yaml
windows_job:
runs-on : windows-latest
steps:
- run: echo Hello, %USERNAME%!
linux_job:
runs-on: ubuntu-latest
steps:
- run: echo "Hello, $USER!"
```
{% endraw %}
</td>
</tr>
</table>
For more information, see "[Workflow syntax for {% data variables.product.prodname_actions %}](/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on)."
### Docker images
Both GitLab CI/CD and {% data variables.product.prodname_actions %} support running jobs in a Docker image. In GitLab CI/CD, Docker images are defined with a `image` key, while in {% data variables.product.prodname_actions %} it is done with the `container` key.
Below is an example of the syntax for each system:
<table class="d-block">
<tr>
<th>
GitLab CI/CD
</th>
<th>
{% data variables.product.prodname_actions %}
</th>
</tr>
<tr>
<td class="d-table-cell v-align-top">
{% raw %}
```yaml
my_job:
image: node:10.16-jessie
```
{% endraw %}
</td>
<td class="d-table-cell v-align-top">
{% raw %}
```yaml
jobs:
my_job:
container: node:10.16-jessie
```
{% endraw %}
</td>
</tr>
</table>
For more information, see "[Workflow syntax for {% data variables.product.prodname_actions %}](/actions/reference/workflow-syntax-for-github-actions#jobsjob_idcontainer)."
### Condition and expression syntax
GitLab CI/CD uses `rules` to determine if a job will run for a specific condition. {% data variables.product.prodname_actions %} uses the `if` keyword to prevent a job from running unless a condition is met.
Below is an example of the syntax for each system:
<table class="d-block">
<tr>
<th>
GitLab CI/CD
</th>
<th>
{% data variables.product.prodname_actions %}
</th>
</tr>
<tr>
<td class="d-table-cell v-align-top">
{% raw %}
```yaml
deploy_prod:
stage: deploy
script:
- echo "Deploy to production server"
rules:
- if: '$CI_COMMIT_BRANCH == "master"'
```
{% endraw %}
</td>
<td class="d-table-cell v-align-top">
{% raw %}
```yaml
jobs:
deploy_prod:
if: contains( github.ref, 'master')
runs-on: ubuntu-latest
steps:
- run: echo "Deploy to production server"
```
{% endraw %}
</td>
</tr>
</table>
For more information, see "[Context and expression syntax for {% data variables.product.prodname_actions %}](/actions/reference/context-and-expression-syntax-for-github-actions)."
### Dependencies between Jobs
Both GitLab CI/CD and {% data variables.product.prodname_actions %} allow you to set dependencies for a job. In both systems, jobs run in parallel by default, but job dependencies in {% data variables.product.prodname_actions %} can be specified explicitly with the `needs` key. GitLab CI/CD also has a concept of `stages`, where jobs in a stage run concurrently, but the next stage will start when all the jobs in the previous stage have completed. You can recreate this scenario in {% data variables.product.prodname_actions %} with the `needs` key.
Below is an example of the syntax for each system. The workflows start with two jobs named `build_a` and `build_b` running in parallel, and when those jobs complete, another job called `test_ab` will run. Finally, when `test_ab` completes, the `deploy_ab` job will run.
<table class="d-block">
<tr>
<th>
GitLab CI/CD
</th>
<th>
{% data variables.product.prodname_actions %}
</th>
</tr>
<tr>
<td class="d-table-cell v-align-top">
{% raw %}
```yaml
stages:
- build
- test
- deploy
build_a:
stage: build
script:
- echo "This job will run first."
build_b:
stage: build
script:
- echo "This job will run first, in parallel with build_a."
test_ab:
stage: test
script:
- echo "This job will run after build_a and build_b have finished."
deploy_ab:
stage: deploy
script:
- echo "This job will run after test_ab is complete"
```
{% endraw %}
</td>
<td class="d-table-cell v-align-top">
{% raw %}
```yaml
jobs:
build_a:
runs-on: ubuntu-latest
steps:
- run: echo "This job will be run first."
build_b:
runs-on: ubuntu-latest
steps:
- run: echo "This job will be run first, in parallel with build_a"
test_ab:
runs-on: ubuntu-latest
needs: [build_a,build_b]
steps:
- run: echo "This job will run after build_a and build_b have finished"
deploy_ab:
runs-on: ubuntu-latest
needs: [test_ab]
steps:
- run: echo "This job will run after test_ab is complete"
```
{% endraw %}
</td>
</tr>
</table>
For more information, see "[Workflow syntax for {% data variables.product.prodname_actions %}](/actions/reference/workflow-syntax-for-github-actions#jobsjob_idneeds)."
### Scheduling workflows
Both GitLab CI/CD and {% data variables.product.prodname_actions %} allow you to run workflows at a specific interval. In GitLab CI/CD, pipeline schedules are configured with the UI, while in {% data variables.product.prodname_actions %} you can trigger a workflow on a scheduled interval with the "on" key.
For more information, see "[Events that trigger workflows](/actions/reference/events-that-trigger-workflows#scheduled-events)."
### Variables and secrets
GitLab CI/CD and {% data variables.product.prodname_actions %} support setting environment variables in the pipeline or workflow configuration file, and creating secrets using the GitLab or {% data variables.product.product_name %} UI.
For more information, see "[Environment variables](/actions/reference/environment-variables)" and "[Encrypted secrets](/actions/reference/encrypted-secrets)."
### Caching
GitLab CI/CD and {% data variables.product.prodname_actions %} provide a method in the configuration file to manually cache workflow files.
Below is an example of the syntax for each system:
<table class="d-block">
<tr>
<th>
GitLab CI/CD
</th>
<th>
{% data variables.product.prodname_actions %}
</th>
</tr>
<tr>
<td class="d-table-cell v-align-top">
{% raw %}
```yaml
image: node:latest
cache:
key: $CI_COMMIT_REF_SLUG
paths:
- .npm/
before_script:
- npm ci --cache .npm --prefer-offline
test_async:
script:
- node ./specs/start.js ./specs/async.spec.js
```
{% endraw %}
</td>
<td class="d-table-cell v-align-top">
{% raw %}
```yaml
jobs:
test_async:
- name: Cache node modules
uses: actions/cache@v2
with:
path: ~/.npm
key: v1-npm-deps-${{ hashFiles('**/package-lock.json') }}
restore-keys: v1-npm-deps-
```
{% endraw %}
</td>
</tr>
</table>
{% data variables.product.prodname_actions %} caching is only applicable to {% data variables.product.prodname_dotcom %}-hosted runners. For more information, see "<a href="/actions/guides/caching-dependencies-to-speed-up-workflows" class="dotcom-only">Caching dependencies to speed up workflows</a>."
### Artifacts
Both GitLab CI/CD and {% data variables.product.prodname_actions %} can upload files and directories created by a job as artifacts. In {% data variables.product.prodname_actions %}, artifacts can be used to persist data across multiple jobs.
Below is an example of the syntax for each system:
<table>
<tr>
<th>
GitLab CI/CD
</th>
<th>
{% data variables.product.prodname_actions %}
</th>
</tr>
<tr>
<td class="d-table-cell v-align-top">
{% raw %}
```yaml
script:
artifacts:
paths:
- math-homework.txt
```
{% endraw %}
</td>
<td class="d-table-cell v-align-top">
{% raw %}
```yaml
- name: Upload math result for job 1
uses: actions/upload-artifact@v2
with:
name: homework
path: math-homework.txt
```
{% endraw %}
</td>
</tr>
</table>
For more information, see "[Storing workflow data as artifacts](/actions/guides/storing-workflow-data-as-artifacts)."
### Databases and service containers
Both systems enable you to include additional containers for databases, caching, or other dependencies.
In GitLab CI/CD, a container for the job is specified with the `image` key, while {% data variables.product.prodname_actions %} uses the `container` key. In both systems, additional service containers are specified with the `services` key.
Below is an example of the syntax for each system:
<table class="d-block">
<tr>
<th>
GitLab CI/CD
</th>
<th>
{% data variables.product.prodname_actions %}
</th>
</tr>
<tr>
<td class="d-table-cell v-align-top">
{% raw %}
```yaml
container-job:
variables:
POSTGRES_PASSWORD: postgres
# The hostname used to communicate with the
# PostgreSQL service container
POSTGRES_HOST: postgres
# The default PostgreSQL port
POSTGRES_PORT: 5432
image: node:10.18-jessie
services:
- postgres
script:
# Performs a clean installation of all dependencies
# in the `package.json` file
- npm ci
# Runs a script that creates a PostgreSQL client,
# populates the client with data, and retrieves data
- node client.js
tags:
- docker
```
{% endraw %}
</td>
<td class="d-table-cell v-align-top">
{% raw %}
```yaml
jobs:
container-job:
runs-on: ubuntu-latest
container: node:10.18-jessie
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: postgres
steps:
- name: Check out repository code
uses: actions/checkout@v2
# Performs a clean installation of all dependencies
# in the `package.json` file
- name: Install dependencies
run: npm ci
- name: Connect to PostgreSQL
# Runs a script that creates a PostgreSQL client,
# populates the client with data, and retrieves data
run: node client.js
env:
# The hostname used to communicate with the
# PostgreSQL service container
POSTGRES_HOST: postgres
# The default PostgreSQL port
POSTGRES_PORT: 5432
```
{% endraw %}
</td>
</tr>
</table>
For more information, see "[About service containers](/actions/guides/about-service-containers)."