diff --git a/public-site/docs/src/.vuepress/config.ts b/public-site/docs/src/.vuepress/config.ts index d7717b72..17ada1b8 100644 --- a/public-site/docs/src/.vuepress/config.ts +++ b/public-site/docs/src/.vuepress/config.ts @@ -72,7 +72,7 @@ export default defineUserConfig({ '/guides/external-alias/', '/guides/component-start-stop-restart/', { - link: '/guides/jobs/', + link: '/guides/jobs/', text: "Jobs", collapsible: true, children: [ @@ -84,7 +84,17 @@ export default defineUserConfig({ '/guides/jobs/openapi-swagger' ] }, - '/guides/deploy-only/', + { + link: '/guides/deploy-only/', + text: "Deploy only", + collapsible: true, + children: [ + '/guides/deploy-only/', + '/guides/deploy-only/example-github-action-to-create-radix-deploy-pipeline-job', + '/guides/deploy-only/example-github-action-using-ad-service-principal-access-token', + '/guides/deploy-only/example-github-action-building-and-deploying-application', + ] + }, '/guides/build-and-deploy/', '/guides/deployment-promotion/', '/guides/monorepo/', @@ -189,4 +199,4 @@ export default defineUserConfig({ }), fullTextSearchPlugin(), ] -}) \ No newline at end of file +}) diff --git a/public-site/docs/src/docs/topic-radix-cli/index.md b/public-site/docs/src/docs/topic-radix-cli/index.md index 9649137d..88886e26 100644 --- a/public-site/docs/src/docs/topic-radix-cli/index.md +++ b/public-site/docs/src/docs/topic-radix-cli/index.md @@ -77,6 +77,7 @@ More details can be found in guidelines and examples: * [Guideline to run "Deploy Only" pipeline job](../../guides/deploy-only/) * [Example of using GitHub action to create a Radix deploy pipeline job](../../guides/deploy-only/example-github-action-to-create-radix-deploy-pipeline-job.md) * [Example of using AD service principal to get access to a Radix application in a GitHub action](../../guides/deploy-only/example-github-action-to-create-radix-deploy-pipeline-job.md) +* [Example of using GitHub Action to build and push container to custom Container Registry](../../guides/deploy-only/example-github-action-building-and-deploying-application.md) ### Commands @@ -110,6 +111,10 @@ Examples of commands: ```shell rx create job build-deploy -a your-app-name --branch main ``` +* Promote active deployment in one environment to another: + ```shell + rx create job promote --application your-app-name --from-environment dev --to-environment prod --use-active-deployment + ``` * Get list of pipeline jobs for a Radix application. `jq` helps to filter returned `json` output ```shell rx get application -a your-app-name | jq -r '.jobs' diff --git a/public-site/docs/src/guides/deploy-only/example-github-action-building-and-deploying-application.md b/public-site/docs/src/guides/deploy-only/example-github-action-building-and-deploying-application.md new file mode 100644 index 00000000..8b63a984 --- /dev/null +++ b/public-site/docs/src/guides/deploy-only/example-github-action-building-and-deploying-application.md @@ -0,0 +1,87 @@ +--- +title: Example of using GitHub Action to build and push container to custom Container Registry +sidebarDepth: 3 +--- + +# Example of using GitHub Action to build and push container to custom Container Registry + +::: tip +This example triggers a deployment directly using Radix CLI with the current commit ID. See [Example of using GitHub action to create a Radix deploy pipeline job](./example-github-action-to-create-radix-deploy-pipeline-job) for how you can modify your `radixconfig.yaml` file with he new image tag instead, and then keep a history of changes in your config file. +::: + +To create a GitHub Actions you need to create a workflow file in the folder `.github/workflows`. + +Steps in the example: + + +* "Az CLI login" - login to the Azure with a service principal - an app registration Application ID or user-assigned managed identity Client ID +* "ACR Login" - login to the Azure Container Registry with service principal +* "RADIX Login" - get an Azure access token for the resource `6dae42f8-4368-4678-94ff-3960e28e3630`, which is a fixed Application ID, corresponding to the Azure Kubernetes Service AAD Server, globally provided by Azure. This token is put to the environment variable `APP_SERVICE_ACCOUNT_TOKEN`, available in following GitHub action job steps +* "Build and push Docker images" - Notice it uses your GitHub Commit SHA to tag your container image. +* "Get environment from branch" - Reads your `radixconfig.yaml` file and figures out which environment to use in the next step +* "Deploy API on Radix" - example of use the [Radix CLI](https://github.com/equinor/radix-cli), In this case to tell Radix to use your newly created image for a component in a specific environment. The Radix CLI in this step expects an environment variable `APP_SERVICE_ACCOUNT_TOKEN` to be set + +```yaml +name: Docker Image CI + +on: + push: + branches: [ "main" ] + +permissions: + id-token: write + contents: read + +jobs: + + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: 'Az CLI login' + uses: azure/login@v1 + with: + client-id: 5e5e5e5e-abcd-efgh-ijkl-f6f6f6f6f6f6 #app registration Application ID or user-assigned managed identity Client ID + tenant-id: 3aa4a235-b6e2-48d5-9195-7fcf05b459b0 + allow-no-subscriptions: true + + - name: ACR Login + run: 'az acr login --name YOUR_ACR_NAME --subscription SUBSCRIPTION_ID' + + - name: RADIX Login + run: | + token=$(az account get-access-token --resource 6dae42f8-4368-4678-94ff-3960e28e3630 --query=accessToken -otsv | tr -d '[:space:]') + echo "::add-mask::$token" + echo "APP_SERVICE_ACCOUNT_TOKEN=$token" >> $GITHUB_ENV + + - name: Build and push Docker images + uses: docker/build-push-action@v5 + with: + push: true + tags: YOUR_ACR_NAME.azurecr.io/ORG/NAME:${{ github.sha }} + + - name: 'Get environment from branch' # for "deploy only" pipeline workflow + id: radix + uses: equinor/radix-github-actions@v1 + with: + args: > + get config branch-environment + --from-config + -b ${GITHUB_REF##*/} + + - name: 'Deploy API on Radix' + uses: equinor/radix-github-actions@v1 + with: + args: > + create job + deploy + --context playground + --from-config + --environment ${{ steps.radix.outputs.result }} + --image-tag-name web=${{ github.sha }} + --follow + +``` diff --git a/public-site/docs/src/guides/monitoring/index.md b/public-site/docs/src/guides/monitoring/index.md index fae03ec6..8865e254 100644 --- a/public-site/docs/src/guides/monitoring/index.md +++ b/public-site/docs/src/guides/monitoring/index.md @@ -7,7 +7,7 @@ sidebarDepth: 3 Prometheus and Grafana are the main tools provided in Radix for analytics and monitoring visualisation. -Click the *`Monitoring`* link in the top right corner of the Radix Web Console, log into Grafana using Azure AD credentials and explore dashboards. +Click the *`Monitoring`* link in the bottom left corner of the Radix Web Console, log into Grafana using Azure AD credentials and explore dashboards. ## Metrics visualisation