2021-09-02 22:03:28 +02:00
|
|
|
---
|
2020-07-17 16:51:32 +02:00
|
|
|
name: Build
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches-ignore:
|
|
|
|
- 'l10n_master'
|
|
|
|
- 'gh-pages'
|
2021-05-04 22:41:49 +02:00
|
|
|
workflow_dispatch:
|
|
|
|
inputs: {}
|
2020-07-17 16:51:32 +02:00
|
|
|
|
|
|
|
jobs:
|
2020-07-17 17:04:21 +02:00
|
|
|
cloc:
|
2021-05-27 16:32:36 +02:00
|
|
|
name: CLOC
|
2021-09-25 00:04:14 +02:00
|
|
|
runs-on: ubuntu-20.04
|
2020-07-17 17:04:21 +02:00
|
|
|
steps:
|
|
|
|
- name: Checkout repo
|
2021-05-17 21:15:01 +02:00
|
|
|
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
|
2020-07-17 17:04:21 +02:00
|
|
|
|
2021-05-27 16:32:36 +02:00
|
|
|
- name: Install cloc
|
2020-07-17 17:04:21 +02:00
|
|
|
run: |
|
|
|
|
sudo apt-get update
|
|
|
|
sudo apt-get -y install cloc
|
|
|
|
|
|
|
|
- name: Print lines of code
|
|
|
|
run: cloc --include-lang C#,SQL,Razor,"Bourne Shell",PowerShell,HTML,CSS,Sass,JavaScript,TypeScript --vcs git
|
|
|
|
|
2021-06-14 21:22:57 +02:00
|
|
|
|
2021-05-04 22:41:49 +02:00
|
|
|
testing:
|
2021-05-27 16:32:36 +02:00
|
|
|
name: Testing
|
2021-09-25 00:04:14 +02:00
|
|
|
runs-on: windows-2019
|
2022-02-10 15:40:31 +01:00
|
|
|
env:
|
|
|
|
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
|
2021-05-04 22:41:49 +02:00
|
|
|
steps:
|
|
|
|
- name: Set up NuGet
|
2021-05-17 21:15:01 +02:00
|
|
|
uses: nuget/setup-nuget@04b0c2b8d1b97922f67eca497d7cf0bf17b8ffe1
|
2021-05-04 22:41:49 +02:00
|
|
|
with:
|
2021-05-27 16:32:36 +02:00
|
|
|
nuget-version: '5'
|
2021-05-04 22:41:49 +02:00
|
|
|
|
|
|
|
- name: Set up MSBuild
|
2021-05-17 21:15:01 +02:00
|
|
|
uses: microsoft/setup-msbuild@c26a08ba26249b81327e26f6ef381897b6a8754d
|
2021-05-04 22:41:49 +02:00
|
|
|
|
|
|
|
- name: Print environment
|
|
|
|
run: |
|
2021-05-17 21:15:01 +02:00
|
|
|
nuget help | grep Version
|
2021-05-04 22:41:49 +02:00
|
|
|
msbuild -version
|
|
|
|
dotnet --info
|
2021-05-17 21:15:01 +02:00
|
|
|
echo "GitHub ref: $GITHUB_REF"
|
|
|
|
echo "GitHub event: $GITHUB_EVENT"
|
2021-05-04 22:41:49 +02:00
|
|
|
|
|
|
|
- name: Checkout repo
|
2021-05-17 21:15:01 +02:00
|
|
|
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
|
2021-05-04 22:41:49 +02:00
|
|
|
|
2022-02-10 15:40:31 +01:00
|
|
|
- uses: actions/cache@937d24475381cd9c75ae6db12cb4e79714b926ed # 2.1.7
|
|
|
|
with:
|
|
|
|
path: ${{ github.workspace }}/.nuget/packages
|
|
|
|
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-nuget-
|
|
|
|
|
2021-05-04 22:41:49 +02:00
|
|
|
- name: Restore
|
2022-02-10 15:40:31 +01:00
|
|
|
run: msbuild /t:restore /p:RestoreLockedMode=true
|
2021-05-04 22:41:49 +02:00
|
|
|
shell: pwsh
|
|
|
|
|
|
|
|
- name: Build solution
|
|
|
|
run: msbuild bitwarden-server.sln /p:Configuration=Debug /verbosity:minimal
|
|
|
|
shell: pwsh
|
2021-12-16 17:47:01 +01:00
|
|
|
|
2021-12-16 08:48:30 +01:00
|
|
|
# TODO: This can be removed when upgrading to .NET 6
|
|
|
|
- name: Restore tools
|
|
|
|
run: dotnet tool restore
|
|
|
|
shell: pwsh
|
|
|
|
|
|
|
|
- name: Verify Format
|
|
|
|
run: dotnet tool run dotnet-format --check
|
|
|
|
shell: pwsh
|
2021-05-04 22:41:49 +02:00
|
|
|
|
2021-10-05 18:12:05 +02:00
|
|
|
- name: Test OSS solution
|
|
|
|
run: dotnet test ./test --configuration Debug --no-build
|
|
|
|
shell: pwsh
|
|
|
|
|
|
|
|
- name: Test Bitwarden solution
|
|
|
|
run: dotnet test ./bitwarden_license/test/CmmCore.Test --configuration Debug --no-build
|
2021-05-04 22:41:49 +02:00
|
|
|
shell: pwsh
|
2020-07-17 16:51:32 +02:00
|
|
|
|
2021-06-14 21:22:57 +02:00
|
|
|
|
2021-09-25 00:04:14 +02:00
|
|
|
build-artifacts:
|
|
|
|
name: Build artifacts
|
|
|
|
runs-on: ubuntu-20.04
|
2021-05-04 22:41:49 +02:00
|
|
|
needs: testing
|
2021-09-25 00:04:14 +02:00
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
include:
|
|
|
|
- service_name: Admin
|
|
|
|
base_path: ./src
|
|
|
|
gulp: true
|
|
|
|
- service_name: Api
|
|
|
|
base_path: ./src
|
|
|
|
- service_name: Billing
|
|
|
|
base_path: ./src
|
|
|
|
- service_name: Events
|
|
|
|
base_path: ./src
|
|
|
|
- service_name: EventsProcessor
|
|
|
|
base_path: ./src
|
|
|
|
- service_name: Icons
|
|
|
|
base_path: ./src
|
|
|
|
- service_name: Identity
|
|
|
|
base_path: ./src
|
|
|
|
- service_name: Notifications
|
|
|
|
base_path: ./src
|
|
|
|
- service_name: Server
|
|
|
|
base_path: ./util
|
|
|
|
- service_name: Setup
|
|
|
|
base_path: ./util
|
|
|
|
- service_name: Sso
|
|
|
|
base_path: ./bitwarden_license/src
|
|
|
|
gulp: true
|
|
|
|
steps:
|
|
|
|
- name: Checkout repo
|
|
|
|
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
|
|
|
|
|
|
|
|
- name: Set up Node
|
|
|
|
uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea
|
|
|
|
with:
|
|
|
|
node-version: '14'
|
|
|
|
|
|
|
|
- name: Update NPM
|
2021-12-08 05:28:13 +01:00
|
|
|
run: npm install -g npm@7
|
2021-09-25 00:04:14 +02:00
|
|
|
|
|
|
|
- name: Print environment
|
|
|
|
run: |
|
|
|
|
whoami
|
|
|
|
dotnet --info
|
|
|
|
node --version
|
|
|
|
npm --version
|
|
|
|
gulp --version
|
|
|
|
echo "GitHub ref: $GITHUB_REF"
|
|
|
|
echo "GitHub event: $GITHUB_EVENT"
|
|
|
|
|
|
|
|
- name: Set up Gulp
|
|
|
|
if: ${{ matrix.gulp }}
|
|
|
|
working-directory: ${{ matrix.base_path }}/${{ matrix.service_name }}
|
2021-12-08 05:28:13 +01:00
|
|
|
run: npm install -g gulp
|
2021-09-25 00:04:14 +02:00
|
|
|
|
|
|
|
- name: Restore/Clean service
|
|
|
|
working-directory: ${{ matrix.base_path }}/${{ matrix.service_name }}
|
|
|
|
run: |
|
|
|
|
echo "Restore"
|
|
|
|
dotnet restore
|
|
|
|
echo "Clean"
|
|
|
|
dotnet clean -c "Release" -o obj/build-output/publish
|
|
|
|
|
|
|
|
- name: Execute Gulp
|
|
|
|
if: ${{ matrix.gulp }}
|
|
|
|
working-directory: ${{ matrix.base_path }}/${{ matrix.service_name }}
|
|
|
|
run: |
|
|
|
|
npm install
|
|
|
|
gulp --gulpfile gulpfile.js build
|
|
|
|
|
|
|
|
- name: Publish service
|
|
|
|
working-directory: ${{ matrix.base_path }}/${{ matrix.service_name }}
|
|
|
|
run: |
|
|
|
|
echo "Publish"
|
|
|
|
dotnet publish -c "Release" -o obj/build-output/publish
|
|
|
|
|
|
|
|
cd obj/build-output/publish
|
|
|
|
zip -r ${{ matrix.service_name }}.zip .
|
|
|
|
mv ${{ matrix.service_name }}.zip ../../../
|
|
|
|
|
|
|
|
pwd
|
|
|
|
ls -atlh ../../../
|
|
|
|
|
|
|
|
- name: Upload service artifact
|
|
|
|
uses: actions/upload-artifact@ee69f02b3dfdecd58bb31b4d133da38ba6fe3700
|
|
|
|
with:
|
|
|
|
name: ${{ matrix.service_name }}.zip
|
2021-10-05 22:40:01 +02:00
|
|
|
path: ${{ matrix.base_path }}/${{ matrix.service_name }}/${{ matrix.service_name }}.zip
|
2021-09-25 00:04:14 +02:00
|
|
|
if-no-files-found: error
|
|
|
|
|
|
|
|
|
|
|
|
build-docker:
|
|
|
|
name: Build Docker images
|
|
|
|
runs-on: ubuntu-20.04
|
|
|
|
needs: build-artifacts
|
2021-05-27 16:32:36 +02:00
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
include:
|
|
|
|
- service_name: Admin
|
|
|
|
base_path: ./src
|
2022-01-24 20:12:37 +01:00
|
|
|
docker_repos: [bitwarden, bitwardenqa.azurecr.io]
|
2021-05-27 16:32:36 +02:00
|
|
|
dotnet: true
|
|
|
|
- service_name: Api
|
|
|
|
base_path: ./src
|
2022-01-24 20:12:37 +01:00
|
|
|
docker_repos: [bitwarden, bitwardenqa.azurecr.io]
|
2021-05-27 16:32:36 +02:00
|
|
|
dotnet: true
|
|
|
|
- service_name: Attachments
|
|
|
|
base_path: ./util
|
2022-01-24 20:12:37 +01:00
|
|
|
docker_repos: [bitwarden, bitwardenqa.azurecr.io]
|
2021-05-27 16:32:36 +02:00
|
|
|
- service_name: Events
|
|
|
|
base_path: ./src
|
2022-01-24 20:12:37 +01:00
|
|
|
docker_repos: [bitwarden, bitwardenqa.azurecr.io]
|
2021-06-14 20:11:05 +02:00
|
|
|
dotnet: true
|
|
|
|
- service_name: EventsProcessor
|
|
|
|
base_path: ./src
|
2022-01-24 20:12:37 +01:00
|
|
|
docker_repos: [bitwardenqa.azurecr.io]
|
2021-05-27 16:32:36 +02:00
|
|
|
dotnet: true
|
|
|
|
- service_name: Icons
|
|
|
|
base_path: ./src
|
2022-01-24 20:12:37 +01:00
|
|
|
docker_repos: [bitwarden, bitwardenqa.azurecr.io]
|
2021-05-27 16:32:36 +02:00
|
|
|
dotnet: true
|
|
|
|
- service_name: Identity
|
|
|
|
base_path: ./src
|
2022-01-24 20:12:37 +01:00
|
|
|
docker_repos: [bitwarden, bitwardenqa.azurecr.io]
|
2021-05-27 16:32:36 +02:00
|
|
|
dotnet: true
|
|
|
|
- service_name: K8S-Proxy
|
|
|
|
base_path: ./util
|
2022-01-24 20:12:37 +01:00
|
|
|
docker_repos: [bitwarden, bitwardenqa.azurecr.io]
|
2021-05-27 16:32:36 +02:00
|
|
|
- service_name: MsSql
|
|
|
|
base_path: ./util
|
2022-01-24 20:12:37 +01:00
|
|
|
docker_repos: [bitwarden, bitwardenqa.azurecr.io]
|
2021-05-27 16:32:36 +02:00
|
|
|
- service_name: Nginx
|
|
|
|
base_path: ./util
|
2022-01-24 20:12:37 +01:00
|
|
|
docker_repos: [bitwarden, bitwardenqa.azurecr.io]
|
2021-05-27 16:32:36 +02:00
|
|
|
- service_name: Notifications
|
|
|
|
base_path: ./src
|
2022-01-24 20:12:37 +01:00
|
|
|
docker_repos: [bitwarden, bitwardenqa.azurecr.io]
|
2021-05-27 16:32:36 +02:00
|
|
|
dotnet: true
|
|
|
|
- service_name: Server
|
|
|
|
base_path: ./util
|
2022-01-24 20:12:37 +01:00
|
|
|
docker_repos: [bitwarden, bitwardenqa.azurecr.io]
|
2021-05-27 16:32:36 +02:00
|
|
|
dotnet: true
|
|
|
|
- service_name: Setup
|
|
|
|
base_path: ./util
|
2022-01-24 20:12:37 +01:00
|
|
|
docker_repos: [bitwarden, bitwardenqa.azurecr.io]
|
2021-05-27 16:32:36 +02:00
|
|
|
dotnet: true
|
|
|
|
- service_name: Sso
|
|
|
|
base_path: ./bitwarden_license/src
|
2022-01-24 20:12:37 +01:00
|
|
|
docker_repos: [bitwarden, bitwardenqa.azurecr.io]
|
2021-05-27 16:32:36 +02:00
|
|
|
dotnet: true
|
2020-07-17 16:51:32 +02:00
|
|
|
steps:
|
2021-05-27 16:32:36 +02:00
|
|
|
- name: Checkout repo
|
|
|
|
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
|
|
|
|
|
2022-01-24 20:12:37 +01:00
|
|
|
########## Build Docker Image ##########
|
2021-06-14 20:11:05 +02:00
|
|
|
- name: Setup service 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"
|
|
|
|
|
2021-09-25 00:04:14 +02:00
|
|
|
- name: Get build artifact
|
2021-05-27 16:32:36 +02:00
|
|
|
if: ${{ matrix.dotnet }}
|
2021-09-25 00:04:14 +02:00
|
|
|
uses: actions/download-artifact@3be87be14a055c47b01d3bd88f8fe02320a9bb60 # v2.0.10
|
|
|
|
with:
|
|
|
|
name: ${{ matrix.service_name }}.zip
|
2021-10-06 19:21:35 +02:00
|
|
|
|
|
|
|
- name: Setup build artifact
|
|
|
|
if: ${{ matrix.dotnet }}
|
|
|
|
run: |
|
2021-10-22 17:41:38 +02:00
|
|
|
mkdir -p ${{ matrix.base_path}}/${{ matrix.service_name }}/obj/build-output/publish
|
2021-11-08 19:39:32 +01:00
|
|
|
unzip ${{ matrix.service_name }}.zip \
|
|
|
|
-d ${{ matrix.base_path }}/${{ matrix.service_name }}/obj/build-output/publish
|
2020-07-17 16:51:32 +02:00
|
|
|
|
2021-05-27 16:32:36 +02:00
|
|
|
- name: Build Docker images
|
|
|
|
run: |
|
2021-09-27 16:23:06 +02:00
|
|
|
if [ "${{ matrix.service_name }}" = "K8S-Proxy" ]; then
|
2021-09-25 00:04:14 +02:00
|
|
|
docker build -f ${{ matrix.base_path }}/Nginx/Dockerfile-k8s \
|
2021-11-15 19:23:51 +01:00
|
|
|
-t ${{ steps.setup.outputs.service_name }} ${{ matrix.base_path }}/Nginx
|
2021-05-27 16:32:36 +02:00
|
|
|
else
|
2021-11-15 19:23:51 +01:00
|
|
|
docker build -t ${{ steps.setup.outputs.service_name }} \
|
2021-09-25 00:04:14 +02:00
|
|
|
${{ matrix.base_path }}/${{ matrix.service_name }}
|
2021-05-27 16:32:36 +02:00
|
|
|
fi
|
|
|
|
|
2022-01-24 20:12:37 +01:00
|
|
|
########## ACR ##########
|
2021-12-08 05:28:13 +01:00
|
|
|
- name: Login to Azure - QA Subscription
|
|
|
|
uses: Azure/login@77f1b2e3fb80c0e8645114159d17008b8a2e475a
|
2021-11-15 19:23:51 +01:00
|
|
|
with:
|
2021-12-08 05:28:13 +01:00
|
|
|
creds: ${{ secrets.AZURE_QA_KV_CREDENTIALS }}
|
2021-11-15 19:23:51 +01:00
|
|
|
|
2021-12-08 05:28:13 +01:00
|
|
|
- name: Login to Azure ACR
|
|
|
|
run: az acr login -n bitwardenqa
|
2021-11-15 19:23:51 +01:00
|
|
|
|
2021-12-08 05:28:13 +01:00
|
|
|
- name: Tag and Push RC to Azure ACR QA registry
|
2021-11-15 19:23:51 +01:00
|
|
|
env:
|
2021-12-08 05:28:13 +01:00
|
|
|
REGISTRY: bitwardenqa.azurecr.io
|
2021-11-15 19:23:51 +01:00
|
|
|
run: |
|
2022-01-24 20:12:37 +01:00
|
|
|
IMAGE_TAG=$(echo "${GITHUB_REF:11}" | sed "s#/#-#g") # slash safe branch name
|
|
|
|
if [[ "$IMAGE_TAG" == "master" ]]; then
|
|
|
|
IMAGE_TAG=dev
|
|
|
|
fi
|
|
|
|
|
2021-11-15 19:23:51 +01:00
|
|
|
docker tag ${{ steps.setup.outputs.service_name }} \
|
2022-01-24 20:12:37 +01:00
|
|
|
$REGISTRY/${{ steps.setup.outputs.service_name }}:$IMAGE_TAG
|
|
|
|
docker push $REGISTRY/${{ steps.setup.outputs.service_name }}:$IMAGE_TAG
|
2021-11-15 19:23:51 +01:00
|
|
|
|
2022-01-24 20:12:37 +01:00
|
|
|
- name: Log out of Docker
|
|
|
|
run: docker logout
|
|
|
|
|
|
|
|
########## DockerHub ##########
|
|
|
|
- name: Login to Azure - Prod Subscription
|
|
|
|
if: |
|
|
|
|
contains(matrix.docker_repos, 'bitwarden')
|
2022-02-09 17:17:17 +01:00
|
|
|
&& (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/rc' || github.ref == 'refs/heads/hotfix-rc')
|
2022-01-24 20:12:37 +01:00
|
|
|
uses: Azure/login@77f1b2e3fb80c0e8645114159d17008b8a2e475a
|
|
|
|
with:
|
|
|
|
creds: ${{ secrets.AZURE_PROD_KV_CREDENTIALS }}
|
|
|
|
|
|
|
|
- name: Retrieve secrets
|
|
|
|
if: |
|
|
|
|
contains(matrix.docker_repos, 'bitwarden')
|
2022-02-09 17:17:17 +01:00
|
|
|
&& (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/rc' || github.ref == 'refs/heads/hotfix-rc')
|
2022-01-24 20:12:37 +01:00
|
|
|
id: retrieve-secrets
|
|
|
|
uses: Azure/get-keyvault-secrets@80ccd3fafe5662407cc2e55f202ee34bfff8c403
|
|
|
|
with:
|
|
|
|
keyvault: "bitwarden-prod-kv"
|
|
|
|
secrets: "docker-password,
|
|
|
|
docker-username,
|
|
|
|
dct-delegate-2-repo-passphrase,
|
|
|
|
dct-delegate-2-key"
|
|
|
|
|
|
|
|
- name: Log into Docker
|
|
|
|
if: |
|
|
|
|
contains(matrix.docker_repos, 'bitwarden')
|
2022-02-09 17:17:17 +01:00
|
|
|
&& (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/rc' || github.ref == 'refs/heads/hotfix-rc')
|
2021-11-15 19:23:51 +01:00
|
|
|
env:
|
2022-01-24 20:12:37 +01:00
|
|
|
DOCKER_USERNAME: ${{ steps.retrieve-secrets.outputs.docker-username }}
|
|
|
|
DOCKER_PASSWORD: ${{ steps.retrieve-secrets.outputs.docker-password }}
|
|
|
|
run: echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
|
2021-11-15 19:23:51 +01:00
|
|
|
|
2022-01-24 20:12:37 +01:00
|
|
|
- name: Setup Docker Trust
|
|
|
|
if: |
|
|
|
|
contains(matrix.docker_repos, 'bitwarden')
|
2022-02-09 17:17:17 +01:00
|
|
|
&& (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/rc' || github.ref == 'refs/heads/hotfix-rc')
|
2021-11-15 19:23:51 +01:00
|
|
|
env:
|
2022-01-24 20:12:37 +01:00
|
|
|
DCT_DELEGATION_KEY_ID: "c9bde8ec820701516491e5e03d3a6354e7bd66d05fa3df2b0062f68b116dc59c"
|
|
|
|
DCT_DELEGATE_KEY: ${{ steps.retrieve-secrets.outputs.dct-delegate-2-key }}
|
|
|
|
DCT_REPO_PASSPHRASE: ${{ steps.retrieve-secrets.outputs.dct-delegate-2-repo-passphrase }}
|
2021-11-15 19:23:51 +01:00
|
|
|
run: |
|
2022-01-24 20:12:37 +01:00
|
|
|
mkdir -p ~/.docker/trust/private
|
|
|
|
echo "$DCT_DELEGATE_KEY" > ~/.docker/trust/private/$DCT_DELEGATION_KEY_ID.key
|
|
|
|
echo "DOCKER_CONTENT_TRUST=1" >> $GITHUB_ENV
|
|
|
|
echo "DOCKER_CONTENT_TRUST_REPOSITORY_PASSPHRASE=$DCT_REPO_PASSPHRASE" >> $GITHUB_ENV
|
|
|
|
|
|
|
|
- name: Tag and Push RC to Docker Hub
|
|
|
|
if: |
|
|
|
|
contains(matrix.docker_repos, 'bitwarden')
|
2022-02-09 17:17:17 +01:00
|
|
|
&& (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/rc' || github.ref == 'refs/heads/hotfix-rc')
|
2022-01-24 21:42:14 +01:00
|
|
|
env:
|
|
|
|
REGISTRY: bitwarden
|
2022-01-24 20:12:37 +01:00
|
|
|
run: |
|
|
|
|
IMAGE_TAG=$(echo "${GITHUB_REF:11}" | sed "s#/#-#g") # slash safe branch name
|
|
|
|
if [[ "$IMAGE_TAG" == "master" ]]; then
|
|
|
|
IMAGE_TAG=dev
|
|
|
|
fi
|
|
|
|
|
2021-11-15 19:23:51 +01:00
|
|
|
docker tag ${{ steps.setup.outputs.service_name }} \
|
2022-01-24 20:12:37 +01:00
|
|
|
$REGISTRY/${{ steps.setup.outputs.service_name }}:$IMAGE_TAG
|
|
|
|
docker push $REGISTRY/${{ steps.setup.outputs.service_name }}:$IMAGE_TAG
|
|
|
|
|
|
|
|
- name: Log out of Docker and disable Docker Notary
|
|
|
|
if: |
|
|
|
|
contains(matrix.docker_repos, 'bitwarden')
|
2022-02-09 17:17:17 +01:00
|
|
|
&& (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/rc' || github.ref == 'refs/heads/hotfix-rc')
|
2022-01-24 20:12:37 +01:00
|
|
|
run: |
|
|
|
|
docker logout
|
|
|
|
echo "DOCKER_CONTENT_TRUST=0" >> $GITHUB_ENV
|
2021-11-15 19:23:51 +01:00
|
|
|
|
2021-06-14 21:22:57 +02:00
|
|
|
|
2021-05-27 16:32:36 +02:00
|
|
|
upload:
|
|
|
|
name: Upload
|
2021-09-25 00:04:14 +02:00
|
|
|
runs-on: ubuntu-20.04
|
|
|
|
needs: build-docker
|
2021-05-27 16:32:36 +02:00
|
|
|
steps:
|
|
|
|
- name: Checkout repo
|
|
|
|
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
|
|
|
|
|
|
|
|
- name: Restore
|
|
|
|
run: dotnet tool restore
|
|
|
|
|
|
|
|
- name: Make Docker stub
|
2022-02-09 17:17:17 +01:00
|
|
|
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/rc' || github.ref == 'refs/heads/hotfix-rc'
|
2020-07-17 16:51:32 +02:00
|
|
|
run: |
|
2021-07-02 19:22:51 +02:00
|
|
|
if [[ "${{ github.ref }}" == "rc" ]]; then
|
|
|
|
SETUP_IMAGE="bitwarden/setup:rc"
|
2022-02-09 17:17:17 +01:00
|
|
|
elif [[ "${{ github.ref }}" == "hotfix-rc" ]]; then
|
|
|
|
SETUP_IMAGE="bitwarden/setup:hotfix-rc"
|
2021-07-02 19:22:51 +02:00
|
|
|
else
|
|
|
|
SETUP_IMAGE="bitwarden/setup:dev"
|
|
|
|
fi
|
|
|
|
|
2020-07-17 16:51:32 +02:00
|
|
|
STUB_OUTPUT=$(pwd)/docker-stub
|
2021-07-02 19:22:51 +02:00
|
|
|
docker run -i --rm --name setup -v $STUB_OUTPUT:/bitwarden $SETUP_IMAGE \
|
2020-07-17 16:51:32 +02:00
|
|
|
dotnet Setup.dll -stub 1 -install 1 -domain bitwarden.example.com -os lin
|
2020-07-17 17:19:00 +02:00
|
|
|
sudo chown -R $(whoami):$(whoami) $STUB_OUTPUT
|
2020-07-17 16:51:32 +02:00
|
|
|
rm -rf $STUB_OUTPUT/letsencrypt
|
|
|
|
rm $STUB_OUTPUT/env/uid.env $STUB_OUTPUT/config.yml
|
|
|
|
touch $STUB_OUTPUT/env/uid.env
|
|
|
|
cd docker-stub; zip -r ../docker-stub.zip *; cd ..
|
|
|
|
|
2021-05-27 16:32:36 +02:00
|
|
|
- name: Upload Docker stub artifact
|
2022-02-09 17:17:17 +01:00
|
|
|
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/rc' || github.ref == 'refs/heads/hotfix-rc'
|
2021-05-17 21:15:01 +02:00
|
|
|
uses: actions/upload-artifact@ee69f02b3dfdecd58bb31b4d133da38ba6fe3700
|
2020-07-17 16:51:32 +02:00
|
|
|
with:
|
|
|
|
name: docker-stub.zip
|
|
|
|
path: ./docker-stub.zip
|
2021-07-02 22:34:20 +02:00
|
|
|
if-no-files-found: error
|
2020-07-17 16:51:32 +02:00
|
|
|
|
2021-05-27 16:32:36 +02:00
|
|
|
- name: Build Swagger
|
2020-07-17 17:19:00 +02:00
|
|
|
run: |
|
|
|
|
cd ./src/Api
|
2021-05-27 16:32:36 +02:00
|
|
|
echo "Restore"
|
|
|
|
dotnet restore
|
|
|
|
echo "Clean"
|
2021-05-27 18:16:12 +02:00
|
|
|
dotnet clean -c "Release" -o obj/build-output/publish
|
2021-05-27 16:32:36 +02:00
|
|
|
echo "Publish"
|
2021-05-27 18:16:12 +02:00
|
|
|
dotnet publish -c "Release" -o obj/build-output/publish
|
2021-05-27 16:32:36 +02:00
|
|
|
|
|
|
|
dotnet swagger tofile --output ../../swagger.json --host https://api.bitwarden.com \
|
2021-05-27 18:16:12 +02:00
|
|
|
./obj/build-output/publish/Api.dll public
|
2020-07-17 17:19:00 +02:00
|
|
|
cd ../..
|
|
|
|
env:
|
|
|
|
ASPNETCORE_ENVIRONMENT: Production
|
|
|
|
swaggerGen: 'True'
|
|
|
|
|
2021-05-27 16:32:36 +02:00
|
|
|
- name: Upload Swagger artifact
|
2021-05-17 21:15:01 +02:00
|
|
|
uses: actions/upload-artifact@ee69f02b3dfdecd58bb31b4d133da38ba6fe3700
|
2020-07-17 17:19:00 +02:00
|
|
|
with:
|
|
|
|
name: swagger.json
|
|
|
|
path: ./swagger.json
|
2021-07-02 22:34:20 +02:00
|
|
|
if-no-files-found: error
|
2021-10-13 21:50:40 +02:00
|
|
|
|
2021-12-16 17:47:01 +01:00
|
|
|
|
2021-10-13 21:50:40 +02:00
|
|
|
check-failures:
|
|
|
|
name: Check for failures
|
|
|
|
if: always()
|
|
|
|
runs-on: ubuntu-20.04
|
|
|
|
needs:
|
|
|
|
- cloc
|
|
|
|
- testing
|
|
|
|
- build-artifacts
|
|
|
|
- build-docker
|
|
|
|
- upload
|
|
|
|
steps:
|
|
|
|
- name: Check if any job failed
|
2021-11-08 19:39:32 +01:00
|
|
|
if: |
|
|
|
|
github.ref == 'refs/heads/master'
|
|
|
|
|| github.ref == 'refs/heads/rc'
|
2022-02-09 17:17:17 +01:00
|
|
|
|| github.ref == 'refs/heads/hotfix-rc'
|
2021-10-13 21:50:40 +02:00
|
|
|
env:
|
|
|
|
CLOC_STATUS: ${{ needs.cloc.result }}
|
|
|
|
TESTING_STATUS: ${{ needs.testing.result }}
|
|
|
|
BUILD_ARTIFACTS_STATUS: ${{ needs.build-artifacts.result }}
|
|
|
|
BUILD_DOCKER_STATUS: ${{ needs.build-docker.result }}
|
|
|
|
UPLOAD_STATUS: ${{ needs.upload.result }}
|
|
|
|
run: |
|
|
|
|
if [ "$CLOC_STATUS" = "failure" ]; then
|
|
|
|
exit 1
|
|
|
|
elif [ "$TESTING_STATUS" = "failure" ]; then
|
|
|
|
exit 1
|
|
|
|
elif [ "$BUILD_ARTIFACTS_STATUS" = "failure" ]; then
|
|
|
|
exit 1
|
|
|
|
elif [ "$BUILD_DOCKER_STATUS" = "failure" ]; then
|
|
|
|
exit 1
|
|
|
|
elif [ "$UPLOAD_STATUS" = "failure" ]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
- name: Login to Azure - Prod Subscription
|
|
|
|
uses: Azure/login@77f1b2e3fb80c0e8645114159d17008b8a2e475a
|
|
|
|
if: failure()
|
|
|
|
with:
|
|
|
|
creds: ${{ secrets.AZURE_PROD_KV_CREDENTIALS }}
|
|
|
|
|
|
|
|
- name: Retrieve secrets
|
|
|
|
id: retrieve-secrets
|
|
|
|
uses: Azure/get-keyvault-secrets@80ccd3fafe5662407cc2e55f202ee34bfff8c403
|
|
|
|
if: failure()
|
|
|
|
with:
|
|
|
|
keyvault: "bitwarden-prod-kv"
|
|
|
|
secrets: "devops-alerts-slack-webhook-url"
|
|
|
|
|
|
|
|
- name: Notify Slack on failure
|
|
|
|
uses: act10ns/slack@e4e71685b9b239384b0f676a63c32367f59c2522 # v1.2.2
|
|
|
|
if: failure()
|
|
|
|
env:
|
|
|
|
SLACK_WEBHOOK_URL: ${{ steps.retrieve-secrets.outputs.devops-alerts-slack-webhook-url }}
|
|
|
|
with:
|
|
|
|
status: ${{ job.status }}
|