1
0
mirror of https://github.com/bitwarden/server synced 2025-12-28 14:13:48 +00:00

Bitwarden Unified Self-Host project (#2410)

This commit is contained in:
Vince Grassia
2022-11-18 14:39:01 -05:00
committed by GitHub
parent 3481fd76c1
commit 194dfe7e14
57 changed files with 1929 additions and 323 deletions

View File

@@ -6,20 +6,19 @@ on:
workflow_dispatch:
inputs:
release_type:
description: 'Release Options'
description: "Release Options"
required: true
default: 'Initial Release'
default: "Initial Release"
type: choice
options:
- Initial Release
- Redeploy
- Dry Run
jobs:
setup:
name: Setup
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
outputs:
release_version: ${{ steps.version.outputs.version }}
branch-name: ${{ steps.branch.outputs.branch-name }}
@@ -51,10 +50,9 @@ jobs:
BRANCH_NAME=$(basename ${{ github.ref }})
echo "::set-output name=branch-name::$BRANCH_NAME"
deploy:
name: Deploy
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
needs:
- setup
strategy:
@@ -81,11 +79,11 @@ jobs:
uses: chrnorm/deployment-action@1b599fe41a0ef1f95191e7f2eec4743f2d7dfc48
id: deployment
with:
token: '${{ secrets.GITHUB_TOKEN }}'
initial-status: 'in_progress'
environment: 'Production Cloud'
task: 'deploy'
description: 'Deploy from ${{ needs.setup.outputs.branch-name }} branch'
token: "${{ secrets.GITHUB_TOKEN }}"
initial-status: "in_progress"
environment: "Production Cloud"
task: "deploy"
description: "Deploy from ${{ needs.setup.outputs.branch-name }} branch"
- name: Download latest Release ${{ matrix.name }} asset
if: ${{ github.event.inputs.release_type != 'Dry Run' }}
@@ -155,22 +153,21 @@ jobs:
if: ${{ github.event.inputs.release_type != 'Dry Run' && success() }}
uses: chrnorm/deployment-status@07b3930847f65e71c9c6802ff5a402f6dfb46b86
with:
token: '${{ secrets.GITHUB_TOKEN }}'
state: 'success'
token: "${{ secrets.GITHUB_TOKEN }}"
state: "success"
deployment-id: ${{ steps.deployment.outputs.deployment_id }}
- name: Update ${{ matrix.name }} deployment status to Failure
if: ${{ github.event.inputs.release_type != 'Dry Run' && failure() }}
uses: chrnorm/deployment-status@07b3930847f65e71c9c6802ff5a402f6dfb46b86
with:
token: '${{ secrets.GITHUB_TOKEN }}'
state: 'failure'
token: "${{ secrets.GITHUB_TOKEN }}"
state: "failure"
deployment-id: ${{ steps.deployment.outputs.deployment_id }}
release-docker:
name: Build Docker images
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
needs:
- setup
env:
@@ -180,38 +177,36 @@ jobs:
fail-fast: false
matrix:
include:
- service_name: Admin
- project_name: Admin
origin_docker_repo: bitwarden
- service_name: Api
- project_name: Api
origin_docker_repo: bitwarden
- service_name: Attachments
- project_name: Attachments
origin_docker_repo: bitwarden
- service_name: Events
- project_name: Events
prod_acr: true
origin_docker_repo: bitwarden
- service_name: EventsProcessor
- project_name: EventsProcessor
prod_acr: true
origin_docker_repo: bitwardenqa.azurecr.io
- service_name: Icons
- project_name: Icons
origin_docker_repo: bitwarden
prod_acr: true
- service_name: Identity
- project_name: Identity
origin_docker_repo: bitwarden
- service_name: K8S-Proxy
- project_name: MsSql
origin_docker_repo: bitwarden
- service_name: MsSql
- project_name: Nginx
origin_docker_repo: bitwarden
- service_name: Nginx
- project_name: Notifications
origin_docker_repo: bitwarden
- service_name: Notifications
- project_name: Server
origin_docker_repo: bitwarden
- service_name: Server
- project_name: Setup
origin_docker_repo: bitwarden
- service_name: Setup
- project_name: Sso
origin_docker_repo: bitwarden
- service_name: Sso
origin_docker_repo: bitwarden
- service_name: Scim
- project_name: Scim
origin_docker_repo: bitwarden
skip_dct: true
steps:
@@ -228,13 +223,13 @@ jobs:
- name: Checkout repo
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
- name: Setup service name
- name: Setup project name
id: setup
run: |
SERVICE_NAME=$(echo "${{ matrix.service_name }}" | awk '{print tolower($0)}')
echo "Matrix name: ${{ matrix.service_name }}"
echo "SERVICE_NAME: $SERVICE_NAME"
echo "::set-output name=service_name::$SERVICE_NAME"
PROJECT_NAME=$(echo "${{ matrix.project_name }}" | awk '{print tolower($0)}')
echo "Matrix name: ${{ matrix.project_name }}"
echo "PROJECT_NAME: $PROJECT_NAME"
echo "::set-output name=project_name::$PROJECT_NAME"
########## DockerHub ##########
- name: Setup DCT
@@ -255,26 +250,26 @@ jobs:
echo "::set-output name=dct_enabled::1"
fi
- name: Pull latest selfhost image
- name: Pull latest project image
if: matrix.origin_docker_repo == 'bitwarden'
env:
SERVICE_NAME: ${{ steps.setup.outputs.service_name }}
PROJECT_NAME: ${{ steps.setup.outputs.project_name }}
run: |
if [[ "${{ github.event.inputs.release_type }}" == "Dry Run" ]]; then
docker pull bitwarden/$SERVICE_NAME:latest
docker pull bitwarden/$PROJECT_NAME:latest
else
docker pull bitwarden/$SERVICE_NAME:$_BRANCH_NAME
docker pull bitwarden/$PROJECT_NAME:$_BRANCH_NAME
fi
- name: Tag version and latest
if: matrix.origin_docker_repo == 'bitwarden'
env:
SERVICE_NAME: ${{ steps.setup.outputs.service_name }}
PROJECT_NAME: ${{ steps.setup.outputs.project_name }}
run: |
if [[ "${{ github.event.inputs.release_type }}" == "Dry Run" ]]; then
docker tag bitwarden/$SERVICE_NAME:latest bitwarden/$SERVICE_NAME:dryrun
docker tag bitwarden/$PROJECT_NAME:latest bitwarden/$PROJECT_NAME:dryrun
else
docker tag bitwarden/$SERVICE_NAME:$_BRANCH_NAME bitwarden/$SERVICE_NAME:$_RELEASE_VERSION
docker tag bitwarden/$PROJECT_NAME:$_BRANCH_NAME bitwarden/$PROJECT_NAME:$_RELEASE_VERSION
fi
- name: Push version and latest image
@@ -282,8 +277,8 @@ jobs:
env:
DOCKER_CONTENT_TRUST: ${{ steps.check-matrix-dct.outputs.dct_enabled }}
DOCKER_CONTENT_TRUST_REPOSITORY_PASSPHRASE: ${{ steps.setup-dct.outputs.dct-delegate-repo-passphrase }}
SERVICE_NAME: ${{ steps.setup.outputs.service_name }}
run: docker push bitwarden/$SERVICE_NAME:$_RELEASE_VERSION
PROJECT_NAME: ${{ steps.setup.outputs.project_name }}
run: docker push bitwarden/$PROJECT_NAME:$_RELEASE_VERSION
- name: Log out of Docker and disable Docker Notary
if: matrix.origin_docker_repo == 'bitwarden'
@@ -300,36 +295,39 @@ jobs:
- name: Login to Azure ACR
run: az acr login -n bitwardenqa
- name: Pull latest selfhost image
- name: Pull latest project image
if: matrix.origin_docker_repo == 'bitwardenqa.azurecr.io'
env:
SERVICE_NAME: ${{ steps.setup.outputs.service_name }}
PROJECT_NAME: ${{ steps.setup.outputs.project_name }}
REGISTRY: bitwardenqa.azurecr.io
run: |
if [[ "${{ github.event.inputs.release_type }}" == "Dry Run" ]]; then
docker pull $REGISTRY/$SERVICE_NAME:latest
docker pull $REGISTRY/$PROJECT_NAME:latest
else
docker pull $REGISTRY/$SERVICE_NAME:$_BRANCH_NAME
docker pull $REGISTRY/$PROJECT_NAME:$_BRANCH_NAME
fi
- name: Tag version and latest
env:
SERVICE_NAME: ${{ steps.setup.outputs.service_name }}
PROJECT_NAME: ${{ steps.setup.outputs.project_name }}
REGISTRY: bitwardenqa.azurecr.io
ORIGIN_REGISTY: ${{ matrix.origin_docker_repo }}
ORIGIN_REGISTRY: ${{ matrix.origin_docker_repo }}
run: |
if [[ "${{ github.event.inputs.release_type }}" == "Dry Run" ]]; then
docker tag $ORIGIN_REGISTY/$SERVICE_NAME:latest $REGISTRY/$SERVICE_NAME:dryrun
docker tag $ORIGIN_REGISTRY/$PROJECT_NAME:latest $REGISTRY/$PROJECT_NAME:dryrun
else
docker tag $ORIGIN_REGISTY/$SERVICE_NAME:$_BRANCH_NAME $REGISTRY/$SERVICE_NAME:$_RELEASE_VERSION
docker tag $ORIGIN_REGISTRY/$PROJECT_NAME:$_BRANCH_NAME $REGISTRY/$PROJECT_NAME:$_RELEASE_VERSION
docker tag $ORIGIN_REGISTRY/$PROJECT_NAME:$_BRANCH_NAME $REGISTRY/$PROJECT_NAME:latest
fi
- name: Push version and latest image
if: ${{ github.event.inputs.release_type != 'Dry Run' }}
env:
SERVICE_NAME: ${{ steps.setup.outputs.service_name }}
PROJECT_NAME: ${{ steps.setup.outputs.project_name }}
REGISTRY: bitwardenqa.azurecr.io
run: docker push $REGISTRY/$SERVICE_NAME:$_RELEASE_VERSION
run: |
docker push $REGISTRY/$PROJECT_NAME:latest
docker push $REGISTRY/$PROJECT_NAME:$_RELEASE_VERSION
- name: Log out of Docker
run: docker logout
@@ -348,31 +346,33 @@ jobs:
- name: Tag version and latest
if: matrix.prod_acr == true
env:
SERVICE_NAME: ${{ steps.setup.outputs.service_name }}
PROJECT_NAME: ${{ steps.setup.outputs.project_name }}
REGISTRY: bitwardenprod.azurecr.io
ORIGIN_REGISTY: ${{ matrix.origin_docker_repo }}
ORIGIN_REGISTRY: ${{ matrix.origin_docker_repo }}
run: |
if [[ "${{ github.event.inputs.release_type }}" == "Dry Run" ]]; then
docker tag $ORIGIN_REGISTY/$SERVICE_NAME:latest $REGISTRY/$SERVICE_NAME:dryrun
docker tag $ORIGIN_REGISTRY/$PROJECT_NAME:latest $REGISTRY/$PROJECT_NAME:dryrun
else
docker tag $ORIGIN_REGISTY/$SERVICE_NAME:$_BRANCH_NAME $REGISTRY/$SERVICE_NAME:$_RELEASE_VERSION
docker tag $ORIGIN_REGISTRY/$PROJECT_NAME:$_BRANCH_NAME $REGISTRY/$PROJECT_NAME:$_RELEASE_VERSION
docker tag $ORIGIN_REGISTRY/$PROJECT_NAME:$_BRANCH_NAME $REGISTRY/$PROJECT_NAME:latest
fi
- name: Push version and latest image
if: ${{ github.event.inputs.release_type != 'Dry Run' && matrix.prod_acr == true }}
env:
SERVICE_NAME: ${{ steps.setup.outputs.service_name }}
PROJECT_NAME: ${{ steps.setup.outputs.project_name }}
REGISTRY: bitwardenprod.azurecr.io
run: docker push $REGISTRY/$SERVICE_NAME:$_RELEASE_VERSION
run: |
docker push $REGISTRY/$PROJECT_NAME:$_RELEASE_VERSION
docker push $REGISTRY/$PROJECT_NAME:latest
- name: Log out of Docker
if: matrix.prod_acr == true
run: docker logout
release:
name: Create GitHub Release
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
needs:
- setup
- deploy
@@ -385,8 +385,8 @@ jobs:
workflow_conclusion: success
branch: ${{ needs.setup.outputs.branch-name }}
artifacts: "docker-stub.zip,
docker-stub-sha256.txt,
swagger.json"
docker-stub-sha256.txt,
swagger.json"
- name: Download latest Release docker-stub
if: ${{ github.event.inputs.release_type == 'Dry Run' }}
@@ -396,16 +396,16 @@ jobs:
workflow_conclusion: success
branch: master
artifacts: "docker-stub.zip,
docker-stub-sha256.txt,
swagger.json"
docker-stub-sha256.txt,
swagger.json"
- name: Create release
if: ${{ github.event.inputs.release_type != 'Dry Run' }}
uses: ncipollo/release-action@40bb172bd05f266cf9ba4ff965cb61e9ee5f6d01
with:
artifacts: 'docker-stub.zip,
docker-stub-sha256.txt,
swagger.json'
artifacts: "docker-stub.zip,
docker-stub-sha256.txt,
swagger.json"
commit: ${{ github.sha }}
tag: "v${{ needs.setup.outputs.release_version }}"
name: "Version ${{ needs.setup.outputs.release_version }}"