GitHub Actions setup
- Create a new repository on GitHub.
- Open your repository on GitHub, then click the tab labeled Settings.
- Click the section labeled Security on the left hand side to expand it.
- Click the link labeled Actions.
- Click the button labeled New repository secret in the top right corner.
- Follow the instructions below for your specific cloud provider:
AWS
- If you haven’t already, create a new AWS ECR repository.
- You’ll need AWS credentials with the following policy permissions:
- In the field labeled Name, enter the value
AWS_ACCESS_KEY_ID. - In the field labeled Secret, enter your AWS Access Key ID.
- Click the button labeled Add secret to save.
- Add a 2nd secret by clicking the button labeled New repository secret in the top right corner.
- In the field labeled Name, enter the value
AWS_SECRET_ACCESS_KEY. - In the field labeled Secret, enter your AWS Secret Access Key.
- Click the button labeled Add secret to save.
- Click on the tab labeled Actions.
- On the left side, click the button labeled New workflow.
- Find the link labeled
set up a workflow yourselfand click it. - Copy the contents from the GitHub Action YAML file for AWS at templates/github_actions/build_and_deploy_to_aws_ecs.yml, and paste it into the textarea.
- Change the following values under the key labeled
env:
- Click the button labeled Start commit in the top right corner.
- Click the button labeled Commit new file.
- Every time you merge a pull request into the master branch, this GitHub Action will run, building a Docker image using your GitHub code, then updating AWS ECS to use the new image with the updated code.
GCP
-
You’ll need to add these roles to the service account that you’ll be using to
deploy Mage from GitHub:
- Artifact Registry Read
- Artifact Registry Writer
- Cloud Run Admin
- Service Account Token Creator
- Service Account User
-
In the field labeled Name, enter the value
GCP_CREDENTIALS. -
In the field labeled Secret, enter the JSON string containing your GCP
service account credentials. It should look something like this:
json { "type": "service_account", "project_id": "mage-123456", "private_key_id": "...", "private_key": "-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n", "client_email": "mage@mage-123456.iam.gserviceaccount.com", "client_id": "...", "auth_uri": "https://accounts.google.com/o/oauth2/auth", "token_uri": "https://oauth2.googleapis.com/token", "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/mage%40mage-123456.iam.gserviceaccount.com" } - Click the button labeled Add secret to save.
- Click on the tab labeled Actions.
- On the left side, click the button labeled New workflow.
-
Find the link labeled
set up a workflow yourselfand click it. - Copy the contents from the GitHub Action YAML file for GCP at templates/github_actions/build_and_deploy_to_gcp_cloud_run.yml, and paste it into the textarea.
-
Change the following values under the key labeled
env: - Click the button labeled Start commit in the top right corner.
- Click the button labeled Commit new file.
- Every time you merge a pull request into the master branch, this GitHub Action will run, building a Docker image using your GitHub code, then updating Google Cloud Run to use the new image with the updated code.
Azure
Mage can be deployed to Azure using GitHub Actions. Our template for deploying to an Azure Container instance is located here and based off the “GitHub Workflow” option in Azure’s docs. To configure this workflow, you will need to add the following secrets to your GitHub repo:
We recommend Microsoft’s Guide for obtaining these credentials via the Azure CLI.
Microsoft also has templates that are similar to ours— we use the
Service ID Principal method for authentication, but you can check Microsoft’s docs for the OpenID Connect method.
Alternatively, you can use the az container app up command in the Deploy to Azure extension in the Azure CLI. This command streamlines creation of the GitHub workflow and deployment steps.