Skip to content

Commit c863361

Browse files
add article
1 parent fdfe196 commit c863361

File tree

2 files changed

+147
-0
lines changed

2 files changed

+147
-0
lines changed
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
---
2+
title: Publish revisions with GitHub Actions in Azure Container Apps Preview
3+
description: Learn to automatically create new revisions using GitHub Actions in Azure Container Apps Preview
4+
services: static-web-apps
5+
author: craigshoemaker
6+
ms.service: static-web-apps
7+
ms.topic: how-to
8+
ms.date: 11/02/2021
9+
ms.author: cshoe
10+
---
11+
12+
# Publish revisions with GitHub Actions in Azure Container Apps Preview
13+
14+
Azure Container Apps allows you to use GitHub Actions to publish [revisions](revisions.md) to your container app. As commits are pushed to your GitHub repository, a GitHub Action is triggered which updates the [container](containers.md) image in the container registry. Once the container is updated in the registry, Azure Container Apps creates a new revision based on the updated container image.
15+
16+
:::image type="content" source="media/github-actions/azure-container-apps-github-actions.png" alt-text="Changes to a GitHub repo trigger an action to create a new revision.":::
17+
18+
The GitHub action is triggered by commits to a specific branch in your repository. When creating the integration link, you decide which branch triggers the action.
19+
20+
## Authentication
21+
22+
When adding or removing a GitHub Actions integration, you can authenticate by either passing in GitHub [personal access token](https://docs.github.com/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token), or using the interactive GitHub login experience. The interactive experience opens a form in your web browser and gives you the opportunity to log in to GitHub. Once successfully authenticated, then a token is passed back to the CLI that is used by GitHub for the rest of current session.
23+
24+
- To pass a personal access token, use the `--token` parameter and provide a token value.
25+
- If you choose to use interactive login, use the `--login-with-github` parameter with no value.
26+
27+
## Add
28+
29+
The `containerapp github-action add` command creates a GitHub Actions integration with your container app.
30+
31+
The first time you attach GitHub Actions to your container app, you need to provide a service principal context. The following command shows you how to create a service principal.
32+
33+
# [Bash](#tab/bash)
34+
35+
```azurecli
36+
az ad sp create-for-rbac \
37+
--name <SERVICE_PRINCIPAL_NAME> \
38+
--role "contributor" \
39+
--scopes "/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP_NAME>" \
40+
--sdk-auth
41+
```
42+
43+
# [PowerShell](#tab/powershell)
44+
45+
```azurecli
46+
az ad sp create-for-rbac `
47+
--name <SERVICE_PRINCIPAL_NAME> `
48+
--role "contributor" `
49+
--scopes "/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP_NAME>" \
50+
--sdk-auth
51+
```
52+
53+
---
54+
55+
The return value from this command is a JSON payload, which includes the service principal's `tenantId`, `cliendId`, and `clientSecret`.
56+
57+
The following example shows you how to add an integration while using a personal access token.
58+
59+
# [Bash](#tab/bash)
60+
61+
```azurecli
62+
az containerapp github-action add \
63+
--repo-url "https://github.com/<OWNER>/<REPOSITORY_NAME>" \
64+
--docker-file-path "./dockerfile" \
65+
--branch <BRANCH_NAME> \
66+
--registry-url <URL_TO_CONTAINER_REGISTRY> \
67+
--registry-user-name <REGISTRY_USER_NAME> \
68+
--registry-password <REGISTRY_PASSWORD> \
69+
--service-principal-client-id <CLIENT_ID> \
70+
--service-principal-client-secret <CLIENT_SECRET> \
71+
--service-principal-tenant-id <TENANT_ID> \
72+
--token <YOUR_GITHUB_PERSONAL_ACCESS_TOKEN>
73+
```
74+
75+
# [PowerShell](#tab/powershell)
76+
77+
```azurecli
78+
az containerapp github-action add `
79+
--repo-url "https://github.com/<OWNER>/<REPOSITORY_NAME>" `
80+
--docker-file-path "./dockerfile" `
81+
--branch <BRANCH_NAME> `
82+
--registry-url <URL_TO_CONTAINER_REGISTRY> `
83+
--registry-user-name <REGISTRY_USER_NAME> `
84+
--registry-password <REGISTRY_PASSWORD> `
85+
--service-principal-client-id <CLIENT_ID> `
86+
--service-principal-client-secret <CLIENT_SECRET> `
87+
--service-principal-tenant-id <TENANT_ID> `
88+
--token <YOUR_GITHUB_PERSONAL_ACCESS_TOKEN>
89+
```
90+
91+
---
92+
93+
As you interact with this example, replace the placeholders surrounded by `<>` with your values.
94+
95+
## Show
96+
97+
The `containerapp github-action show` command returns the GitHub Actions configuration settings for a container app.
98+
99+
This example shows how to add an integration while using the personal access token.
100+
101+
# [Bash](#tab/bash)
102+
103+
```azurecli
104+
az containerapp github-action show \
105+
--resource-group <RESOURCE_GROUP_NAME> \
106+
--name <CONTAINER_APP_NAME>
107+
```
108+
109+
# [PowerShell](#tab/powershell)
110+
111+
```azurecli
112+
az containerapp github-action show `
113+
--resource-group <RESOURCE_GROUP_NAME> `
114+
--name <CONTAINER_APP_NAME>
115+
```
116+
117+
---
118+
119+
As you interact with this example, replace the placeholders surrounded by `<>` with your values.
120+
121+
This command returns a JSON payload with the GitHub Actions integration configuration settings.
122+
123+
## Delete
124+
125+
The `containerapp github-action remove` command removes the GitHub Actions from the container app.
126+
127+
# [Bash](#tab/bash)
128+
129+
```azurecli
130+
az containerapp github-action remove \
131+
--resource-group <RESOURCE_GROUP_NAME> \
132+
--name <CONTAINER_APP_NAME> \
133+
--token <YOUR_GITHUB_PERSONAL_ACCESS_TOKEN>
134+
```
135+
136+
# [PowerShell](#tab/powershell)
137+
138+
```azurecli
139+
az containerapp github-action remove `
140+
--resource-group <RESOURCE_GROUP_NAME> `
141+
--name <CONTAINER_APP_NAME> `
142+
--token <YOUR_GITHUB_PERSONAL_ACCESS_TOKEN>
143+
```
144+
145+
---
146+
147+
As you interact with this example, replace the placeholders surrounded by `<>` with your values.
30.2 KB
Loading

0 commit comments

Comments
 (0)