Files
self-host/.github/workflows/release-digital-ocean.yml
renovate[bot] dbb45e25e0 [deps]: Update actions/checkout action to v6 (#437)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-12-10 10:01:41 -05:00

89 lines
2.7 KiB
YAML

name: Release Digital Ocean 1-Click
on:
release:
types: [published]
push:
paths:
- "DigitalOceanMarketplace/**"
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: false
permissions:
contents: read
jobs:
build-image:
name: Build Image
runs-on: ubuntu-24.04
timeout-minutes: 90
permissions:
contents: read
id-token: write
steps:
- name: Checkout repo
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
persist-credentials: false
- name: Log in to Azure
uses: bitwarden/gh-actions/azure-login@main
with:
subscription_id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
tenant_id: ${{ secrets.AZURE_TENANT_ID }}
client_id: ${{ secrets.AZURE_CLIENT_ID }}
- name: Retrieve secrets
id: retrieve-secrets
uses: bitwarden/gh-actions/get-keyvault-secrets@main
with:
keyvault: "bitwarden-ci"
secrets: "digital-ocean-api-key"
- name: Log out from Azure
uses: bitwarden/gh-actions/azure-logout@main
- name: Set version from version.json
id: set-version
run: |
VERSION=$(jq -r '.versions.coreVersion' version.json)
if [[ -z "$VERSION" ]]; then
echo "ERROR: Failed to extract coreVersion from version.json"
exit 1
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Set up Hashicorp Packer
uses: hashicorp/setup-packer@1aa358be5cf73883762b302a3a03abd66e75b232 # v3.1.0
- name: Build Digital Ocean Image
env:
DIGITALOCEAN_TOKEN: ${{ steps.retrieve-secrets.outputs.digital-ocean-api-key }}
DIGITALOCEAN_IMG_VERSION: ${{ steps.set-version.outputs.version }}
working-directory: ./DigitalOceanMarketplace
run: |
packer version
packer init -upgrade marketplace-image.pkr.hcl
packer build marketplace-image.pkr.hcl
- name: Install doctl
if: ${{ github.event_name != 'release' && github.event_name != 'workflow_dispatch' }}
uses: digitalocean/action-doctl@135ac0aa0eed4437d547c6f12c364d3006b42824 # v2.5.1
with:
token: ${{ steps.retrieve-secrets.outputs.digital-ocean-api-key }}
- name: Digital Ocean Image Cleanup
working-directory: ./DigitalOceanMarketplace
if: ${{ github.event_name != 'release' && github.event_name != 'workflow_dispatch' }}
run: |
# Get the ID from the snapshot build.
DO_ARTIFACT=$(jq -r '.builds[-1].artifact_id' manifest.json | cut -d ":" -f2)
# Force remove the snapshot
doctl compute image delete "$DO_ARTIFACT" -f