Skip to content

Commit 9115c64

Browse files
github actions tutorial
1 parent 82c48f1 commit 9115c64

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed

docs/tutorials/github-actions.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
title: Deploying from GitHub Actions
3+
description: Using the Defang Github Action to deploy your project from your CI/CD pipeline.
4+
---
5+
6+
# Deploying from GitHub Actions
7+
8+
This tutorial will show you how to use the [Defang GitHub Action](https://github.com/DefangLabs/defang-github-action) to deploy your project from your GitHub Actions workflow.
9+
10+
## Prerequisites
11+
12+
- [A Defang Account](/docs/concepts/authentication)
13+
- [A Github Repo](https://docs.github.com/en/get-started/quickstart/create-a-repo)
14+
15+
## Step 1 - Create a new GitHub Actions workflow
16+
17+
### AWS
18+
19+
In your GitHub repository, create a new file at `.github/workflows/deploy.yml` with the following content:
20+
21+
```yaml
22+
name: Deploy to Defang
23+
on:
24+
push:
25+
branches:
26+
- main # Change this to your default branch if it's not 'main'
27+
jobs:
28+
deploy:
29+
runs-on: ubuntu-latest
30+
permissions:
31+
contents: read
32+
id-token: write
33+
34+
steps:
35+
- name: Configure AWS Credentials for CI
36+
uses: aws-actions/configure-aws-credentials@v4
37+
with:
38+
aws-region: us-west-2
39+
role-to-assume: arn:aws:iam::123456789012:role/ci-role
40+
41+
- name: Checkout Repo
42+
uses: actions/checkout@v4
43+
44+
- name: Deploy
45+
uses: DefangLabs/[email protected]
46+
with:
47+
mode: "balanced"
48+
provider: "aws"
49+
```
50+
51+
### GCP
52+
53+
```yaml
54+
name: Deploy to Defang
55+
on:
56+
push:
57+
branches:
58+
- main # Change this to your default branch if it's not 'main'
59+
jobs:
60+
deploy:
61+
runs-on: ubuntu-latest
62+
permissions:
63+
contents: read
64+
id-token: write
65+
66+
steps:
67+
- name: Configure GCP Credentials for Prod
68+
uses: "google-github-actions/auth@v2"
69+
with:
70+
workload_identity_provider: "projects/123456789012/locations/global/workloadIdentityPools/github-actions-pool/providers/my-project-repo-provider"
71+
72+
- name: Checkout Repo
73+
uses: actions/checkout@v4
74+
75+
- name: Deploy
76+
uses: DefangLabs/[email protected]
77+
with:
78+
mode: "balanced"
79+
provider: "gcp"
80+
```
81+
82+
Full documentation for configuring AWS and GCP credentials can be found in the [Defang GitHub Action repository](https://github.com/DefangLabs/defang-github-action).
83+
84+

0 commit comments

Comments
 (0)