### Update Container Image Tag Source: https://github.com/digitalocean/app_action/blob/main/README.md This example demonstrates how to update a container image tag for a specific service within an app. The `IMAGE_TAG_SAMPLE_SERVICE` environment variable is used to specify the new tag, which will override the tag defined in the app spec. ```yaml - name: Deploy the app uses: digitalocean/app_action/deploy@v2 env: IMAGE_TAG_SAMPLE_SERVICE: v2 with: token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} app_name: sample-app ``` -------------------------------- ### Deploy App from Prebuilt Docker Image Source: https://github.com/digitalocean/app_action/blob/main/README.md This action deploys an app using a prebuilt Docker image specified by its digest. It includes steps for logging into a container registry, building and pushing the Docker image, and then deploying the app. ```yaml name: Build, Push and Deploy a Docker Image on: push: branches: [main] permissions: contents: read packages: write jobs: build-push-deploy-image: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 - name: Log in to the Container registry uses: docker/login-action@v3.3.0 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push Docker image id: push uses: docker/build-push-action@v6.5.0 with: context: . push: true tags: ghcr.io/${{ github.repository }}:latest - name: Deploy the app uses: digitalocean/app_action/deploy@v2 env: SAMPLE_DIGEST: ${{ steps.push.outputs.digest }} GHCR_CREDENTIALS: ${{ secrets.GHCR_CREDENTIALS }} with: token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} ``` -------------------------------- ### App Platform Preview Deployment Workflow Source: https://context7.com/digitalocean/app_action/llms.txt Deploys preview apps automatically on pull requests and comments on the PR with the live URL upon success. Requires `GITHUB_TOKEN` with `pull-requests: write` permission. ```yaml # .do/app.yaml name: sample services: - name: sample github: branch: main repo: your-org/your-repo ``` ```yaml # .github/workflows/preview-deploy.yml name: App Platform Preview on: pull_request: branches: [main] permissions: contents: read pull-requests: write jobs: preview: name: Deploy Preview runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 - name: Deploy preview app id: deploy uses: digitalocean/app_action/deploy@v2 with: deploy_pr_preview: "true" token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} - name: Comment on PR with success uses: actions/github-script@v7 with: script: | github.rest.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, body: `🚀 Preview app deployed successfully!\n\n**Live URL:** ${{ fromJson(steps.deploy.outputs.app).live_url }}` }) - name: Comment on PR with failure if: failure() uses: actions/github-script@v7 env: BUILD_LOGS: ${{ steps.deploy.outputs.build_logs }} DEPLOY_LOGS: ${{ steps.deploy.outputs.deploy_logs }} with: script: | const { BUILD_LOGS, DEPLOY_LOGS } = process.env github.rest.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, body: `❌ Preview deployment failed.\n\n[View logs](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})\n\n
\nBuild logs\n\n```\n${BUILD_LOGS}\n```\n
\n\n
\nDeploy logs\n\n```\n${DEPLOY_LOGS}\n```\n
` ``` -------------------------------- ### Basic Deployment Workflow Source: https://context7.com/digitalocean/app_action/llms.txt A GitHub Actions workflow to deploy an application using an in-repository app spec. It checks out the repository, sets up secrets for the DigitalOcean token and application variables, and then uses the app action for deployment. ```yaml # .github/workflows/deploy.yml name: Deploy App on: push: branches: [main] permissions: contents: read jobs: deploy: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 - name: Deploy to App Platform uses: digitalocean/app_action/deploy@v2 env: DATABASE_URL: ${{ secrets.DATABASE_URL }} API_KEY: ${{ secrets.API_KEY }} with: token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} print_build_logs: "true" print_deploy_logs: "true" ``` -------------------------------- ### Deploy App with Preview Feature Source: https://github.com/digitalocean/app_action/blob/main/README.md This GitHub Actions workflow deploys an app and enables the preview feature for pull requests. It posts a success comment with the live URL or a failure comment with logs if the deployment fails. Ensure the DIGITALOCEAN_ACCESS_TOKEN secret is configured. ```yaml name: App Platform Preview on: pull_request: branches: [main] permissions: contents: read pull-requests: write jobs: test: name: preview runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 - name: Deploy the app id: deploy uses: digitalocean/app_action/deploy@v2 with: deploy_pr_preview: "true" token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} - uses: actions/github-script@v7 env: BUILD_LOGS: ${{ steps.deploy.outputs.build_logs }} DEPLOY_LOGS: ${{ steps.deploy.outputs.deploy_logs }} with: script: | const { BUILD_LOGS, DEPLOY_LOGS } = process.env github.rest.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, body: ":rocket: :rocket: :rocket: The app was successfully deployed at ${{ fromJson(steps.deploy.outputs.app).live_url }}}." }) - uses: actions/github-script@v7 if: failure() with: script: | github.rest.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, body: `The app failed to be deployed. Logs can be found [here](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}). ## Logs
Build logs ``` ${BUILD_LOGS} ```
Deploy logs ``` ${DEPLOY_LOGS} ```
` }) ``` -------------------------------- ### Deploy App Action Source: https://github.com/digitalocean/app_action/blob/main/README.md This action deploys an application to DigitalOcean App Platform. It supports deploying from an in-repository app specification file or an existing app, and can print build and deploy logs. ```APIDOC ## POST /deploy ### Description Deploys an application to DigitalOcean App Platform using a GitHub Action. It can create a new app from an in-repository specification or update an existing one. It also supports preview deployments for pull requests. ### Method POST ### Endpoint /deploy ### Parameters #### Inputs - **token** (string) - Required - DigitalOcean Personal Access Token. See https://docs.digitalocean.com/reference/api/create-personal-access-token/ for creating a new token. - **app_spec_location** (string) - Optional - Location of the app spec file. Defaults to `.do/app.yaml`. - **project_id** (string) - Optional - ID of the project to deploy the app to. If not given, the app will be deployed to the default project. - **app_name** (string) - Optional - Name of the app to pull the spec from. The app must already exist. If an app name is given, a potential in-repository app spec is ignored. - **print_build_logs** (boolean) - Optional - Print build logs. Defaults to `false`. - **print_deploy_logs** (boolean) - Optional - Print deploy logs. Defaults to `false`. - **deploy_pr_preview** (boolean) - Optional - Deploy the app as a PR preview. The app name will be derived from the PR, the app spec will be modified to exclude conflicting configuration like domains and alerts and all Github references to the current repository will be updated to point to the PR's branch. Defaults to `false`. ### Outputs #### Success Response (200) - **app** (object) - A JSON representation of the entire app after the deployment. - **build_logs** (string) - The builds logs of the deployment. - **deploy_logs** (string) - The deploy logs of the deployment. ``` -------------------------------- ### Environment Variable Substitution in App Spec Source: https://context7.com/digitalocean/app_action/llms.txt Demonstrates how to use environment variables within the .do/app.yaml file. This includes substituting GitHub secrets, preserving DigitalOcean bindable variables (containing dots), and app-wide variables. ```yaml # .do/app.yaml - Demonstrates variable substitution name: sample services: - name: api envs: # GitHub secret substituted at deploy time - key: DATABASE_URL value: ${DATABASE_URL} type: SECRET # Bindable variable preserved (contains dots) - key: REDIS_URL value: ${db.REDIS_URL} # App-wide variable preserved - key: CURRENT_APP_URL value: ${APP_URL} github: branch: main repo: your-org/your-repo ``` -------------------------------- ### PR Preview Cleanup Workflow Source: https://context7.com/digitalocean/app_action/llms.txt Automatically deletes preview apps when pull requests are closed. It uses `from_pr_preview: "true"` to identify the correct app and `ignore_not_found: "true"` to prevent errors if the app is already gone. The `token` input is required. ```yaml # .github/workflows/preview-cleanup.yml name: Delete Preview on: pull_request: types: [closed] jobs: cleanup: runs-on: ubuntu-latest steps: - name: Delete preview app uses: digitalocean/app_action/delete@v2 with: from_pr_preview: "true" ignore_not_found: "true" token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} ``` -------------------------------- ### Build and Deploy Docker Image Workflow Source: https://context7.com/digitalocean/app_action/llms.txt A workflow that builds and pushes a Docker image to GHCR, then deploys it to App Platform using the image digest. It requires permissions for contents and packages, logs into GHCR, builds the image, and uses the app action for deployment. ```yaml # .github/workflows/build-deploy.yml name: Build and Deploy Docker Image on: push: branches: [main] permissions: contents: read packages: write jobs: build-and-deploy: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 - name: Log in to GitHub Container Registry uses: docker/login-action@v3.3.0 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push Docker image id: push uses: docker/build-push-action@v6.5.0 with: context: . push: true tags: ghcr.io/${{ github.repository }}:latest - name: Deploy to App Platform uses: digitalocean/app_action/deploy@v2 env: SAMPLE_DIGEST: ${{ steps.push.outputs.digest }} GHCR_CREDENTIALS: ${{ secrets.GHCR_CREDENTIALS }} with: token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} ``` -------------------------------- ### Deploy App with Referenced Secret Source: https://github.com/digitalocean/app_action/blob/main/README.md Use this action to deploy an app defined in `.do/app.yaml` and pass repository secrets as environment variables. Ensure the environment variable type is set to `SECRET` in the app spec for encrypted storage. ```yaml name: Update App on: push: branches: [main] permissions: contents: read jobs: deploy-app: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 - name: Deploy the app uses: digitalocean/app_action/deploy@v2 env: SOME_SECRET_FROM_REPOSITORY: ${{ secrets.SOME_SECRET_FROM_REPOSITORY }} with: token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} ``` -------------------------------- ### App Spec for Basic Deployment Source: https://context7.com/digitalocean/app_action/llms.txt Defines an application's services, environment variables (including secrets), and GitHub repository details. Ensure secrets like DATABASE_URL and API_KEY are provided via GitHub secrets. ```yaml # .do/app.yaml name: sample services: - name: sample envs: - key: DATABASE_URL value: ${DATABASE_URL} type: SECRET - key: API_KEY value: ${API_KEY} type: SECRET github: branch: main repo: your-org/your-repo ``` -------------------------------- ### Deploy App to Specific Project Source: https://context7.com/digitalocean/app_action/llms.txt Deploy an app to a specific DigitalOcean project by providing the project ID. Ensure your DigitalOcean Personal Access Token is configured as a secret. ```yaml # .github/workflows/deploy-to-project.yml name: Deploy to Project on: push: branches: [main] jobs: deploy: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 - name: Deploy to specific project uses: digitalocean/app_action/deploy@v2 with: token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} project_id: "12345678-1234-1234-1234-123456789abc" ``` -------------------------------- ### App Spec for Prebuilt Docker Image Source: https://context7.com/digitalocean/app_action/llms.txt Configures an application service to use a prebuilt Docker image from GitHub Container Registry (GHCR). It specifies the registry, repository, and uses environment variables for credentials and the image digest. ```yaml # .do/app.yaml name: sample services: - name: sample image: registry_type: GHCR registry: your-org repository: your-repo registry_credentials: ${GHCR_CREDENTIALS} digest: ${SAMPLE_DIGEST} ``` -------------------------------- ### Update Image References with Environment Variables Source: https://context7.com/digitalocean/app_action/llms.txt Shows how to dynamically update container image references in a GitHub Actions workflow using environment variables. Component names are converted to uppercase with dashes replaced by underscores for environment variable naming. ```yaml # .github/workflows/deploy-image.yml name: Deploy Specific Image on: workflow_dispatch: jobs: deploy: runs-on: ubuntu-latest steps: - name: Deploy with image digest uses: digitalocean/app_action/deploy@v2 env: # For component named "web-service", use IMAGE_DIGEST_WEB_SERVICE IMAGE_DIGEST_WEB_SERVICE: sha256:abc123... # Or use tag instead IMAGE_TAG_WORKER_SERVICE: v2.1.0 with: token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} app_name: my-app ``` -------------------------------- ### Delete App by Name Source: https://context7.com/digitalocean/app_action/llms.txt Delete an application by specifying its name directly. This is useful for cleaning up preview apps or removing deprecated applications. The `token` input is required. ```yaml # .github/workflows/delete-app.yml name: Delete Application on: workflow_dispatch: inputs: app_name: description: 'Name of the app to delete' required: true jobs: delete: runs-on: ubuntu-latest steps: - name: Delete app uses: digitalocean/app_action/delete@v2 with: token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} app_name: ${{ github.event.inputs.app_name }} ``` -------------------------------- ### Update Existing App Image Tag Workflow Source: https://context7.com/digitalocean/app_action/llms.txt A workflow triggered manually to update an existing app's Docker image tag. It uses the `app_name` input to target a specific app and an environment variable to pass the new image tag, allowing updates without modifying the app spec. ```yaml # .github/workflows/update-image.yml name: Update App Image on: workflow_dispatch: inputs: image_tag: description: 'Docker image tag to deploy' required: true jobs: deploy: runs-on: ubuntu-latest steps: - name: Deploy updated image uses: digitalocean/app_action/deploy@v2 env: IMAGE_TAG_SAMPLE_SERVICE: ${{ github.event.inputs.image_tag }} with: token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} app_name: sample-app ``` -------------------------------- ### Delete App by ID Source: https://context7.com/digitalocean/app_action/llms.txt Delete an application using its unique identifier. The `ignore_not_found` input is set to `true` to prevent failures if the app does not exist. The `token` input is required. ```yaml # .github/workflows/delete-by-id.yml name: Delete Application by ID on: workflow_dispatch: inputs: app_id: description: 'ID of the app to delete' required: true jobs: delete: runs-on: ubuntu-latest steps: - name: Delete app by ID uses: digitalocean/app_action/delete@v2 with: token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} app_id: ${{ github.event.inputs.app_id }} ignore_not_found: "true" ``` -------------------------------- ### Delete App Action Source: https://github.com/digitalocean/app_action/blob/main/README.md This action deletes a specified application from DigitalOcean App Platform. It can delete by app ID or name, and supports ignoring cases where the app is not found. ```APIDOC ## DELETE /delete ### Description Deletes an application from DigitalOcean App Platform using a GitHub Action. It can target an app by its ID or name, and has an option to ignore errors if the app does not exist. ### Method DELETE ### Endpoint /delete ### Parameters #### Inputs - **token** (string) - Required - DigitalOcean Personal Access Token. See https://docs.digitalocean.com/reference/api/create-personal-access-token/ for creating a new token. - **app_id** (string) - Optional - ID of the app to delete. - **app_name** (string) - Optional - Name of the app to delete. - **from_pr_preview** (boolean) - Optional - Use this if the app was deployed as a PR preview. The app name will be derived from a combination of the repo name and the PR. - **ignore_not_found** (boolean) - Optional - Ignore if the app is not found. ``` -------------------------------- ### Delete Preview App on PR Close Source: https://github.com/digitalocean/app_action/blob/main/README.md This GitHub Actions workflow automatically deletes the preview app when a pull request is closed. It uses the `delete` action and is configured to ignore errors if the app is not found. ```yaml name: Delete Preview on: pull_request: types: [ closed ] jobs: closed: runs-on: ubuntu-latest steps: - name: delete preview app uses: digitalocean/app_action/delete@v2 with: from_pr_preview: "true" ignore_not_found: "true" token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.