Skip to content

Latest commit

 

History

History
226 lines (166 loc) · 8.92 KB

File metadata and controls

226 lines (166 loc) · 8.92 KB

GitHub Reusable Workflow: Clean deploy

Clean deploy

Release License Stars PRs Welcome

Overview

Reusable workflow to clean some deployment.

Deletes one or more deployments and runs a follow-up "clean" action (for example a repository-dispatch) to perform any repository-specific cleanup required after deployment removal. The workflow can be triggered on-demand via a given comment trigger (e.g. /undeploy).

Behavior / outputs:

  • Deletes matching deployment(s) via the local action at ./actions/deployment/delete.
  • Exposes deleted environments in step output environments.
  • If environments were deleted the workflow will optionally trigger the configured clean action (e.g. repository-dispatch) against the target repository and post a summary comment.

Permissions

  • actions: read
  • deployments: write
  • issues: write
  • pull-requests: write

Usage

name: Clean deploy
on:
  push:
    branches:
      - main
permissions: {}
jobs:
  clean-deploy:
    uses: hoverkraft-tech/ci-github-publish/.github/workflows/clean-deploy.yml@91a69c7a9730d3ec2886a80681dbb67634c70970 # 0.23.1
    permissions: {}
    secrets:
      # GitHub token for deploying.
      # Permissions:
      # - contents: write
      github-token: ""

      # GitHub App private key to generate GitHub token in place of github-token.
      # See https://github.com/actions/create-github-app-token.
      github-app-key: ""
    with:
      # JSON array of runner(s) to use.
      # See https://docs.github.com/en/actions/using-jobs/choosing-the-runner-for-a-job.
      #
      # Default: `["ubuntu-latest"]`
      runs-on: '["ubuntu-latest"]'

      # GitHub App Client ID to generate GitHub token in place of github-token.
      # See https://github.com/actions/create-github-app-token.
      github-app-client-id: ""

      # Type of clean-deploy action.
      # Supported values:
      # - [`repository-dispatch`](../../actions/clean-deploy/repository-dispatch/README.md).
      #
      # Default: `repository-dispatch`
      clean-deploy-type: repository-dispatch

      # Inputs to pass to the clean action.
      # JSON object, depending on the clean-deploy-type.
      # For example, for `repository-dispatch`:
      # ```json
      # {
      # "repository": "my-org/my-repo"
      # }
      # ```
      clean-deploy-parameters: ""

      # Comment trigger to start the workflow.
      # See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#issue_comment.
      #
      # Default: `/undeploy`
      trigger-on-comment: /undeploy

Inputs

Workflow Call Inputs

Input Description Required Type Default
runs-on JSON array of runner(s) to use. false string ["ubuntu-latest"]
See https://docs.github.com/en/actions/using-jobs/choosing-the-runner-for-a-job.
github-app-client-id GitHub App Client ID to generate GitHub token in place of github-token. false string -
See https://github.com/actions/create-github-app-token.
clean-deploy-type Type of clean-deploy action. false string repository-dispatch
Supported values:
- repository-dispatch.
clean-deploy-parameters Inputs to pass to the clean action. false string -
JSON object, depending on the clean-deploy-type.
For example, for repository-dispatch:
{
 "repository": "my-org/my-repo"
}
trigger-on-comment Comment trigger to start the workflow. false string /undeploy
See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#issue_comment.

Secrets

Secret Description Required
github-token GitHub token for deploying. false
Permissions:
- contents: write
github-app-key GitHub App private key to generate GitHub token in place of github-token. false
See https://github.com/actions/create-github-app-token.

Examples

Clean ArgoCD review-app deployment on closed pull-request (or on demand with /undeploy comment) using GitHub App token

---
name: "Clean deploy"
on:
  pull_request_target:
    types: [closed]
  issue_comment:
    types: [created]

permissions:
  contents: write
  issues: write
  packages: write
  pull-requests: write
  actions: read
  deployments: write
  id-token: write

jobs:
  clean-deploy:
    uses: hoverkraft-tech/ci-github-publish/.github/workflows/clean-deploy.yml@91a69c7a9730d3ec2886a80681dbb67634c70970 # 0.23.1
    with:
      clean-deploy-parameters: |
        { "repository": "${{ github.repository_owner }}/argocd-app-of-apps" }
      github-app-id: ${{ vars.CI_BOT_APP_ID }}
    secrets:
      github-app-key: ${{ secrets.CI_BOT_APP_PRIVATE_KEY }}

Contributing

Contributions are welcome! Please see the contributing guidelines for more details.

License

This project is licensed under the MIT License.

SPDX-License-Identifier: MIT

Copyright © 2026 hoverkraft-tech

For more details, see the license.


This documentation was automatically generated by CI Dokumentor.