2021-09-02 22:03:28 +02:00
|
|
|
---
|
2020-07-17 16:51:32 +02:00
|
|
|
name: Build
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches-ignore:
|
2022-10-04 23:23:43 +02:00
|
|
|
- "l10n_master"
|
|
|
|
- "gh-pages"
|
2022-02-23 17:29:19 +01:00
|
|
|
paths-ignore:
|
2022-10-04 23:23:43 +02:00
|
|
|
- ".github/workflows/**"
|
2021-05-04 22:41:49 +02:00
|
|
|
workflow_dispatch:
|
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
|
2022-11-18 20:39:01 +01:00
|
|
|
runs-on: ubuntu-22.04
|
2020-07-17 17:04:21 +02:00
|
|
|
steps:
|
|
|
|
- name: Checkout repo
|
2023-07-03 18:36:42 +02:00
|
|
|
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
|
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
|
|
|
|
|
2022-03-14 14:31:03 +01:00
|
|
|
lint:
|
|
|
|
name: Lint
|
2022-11-18 20:39:01 +01:00
|
|
|
runs-on: ubuntu-22.04
|
2022-03-14 14:31:03 +01:00
|
|
|
steps:
|
|
|
|
- name: Checkout repo
|
2023-07-03 18:36:42 +02:00
|
|
|
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
|
2022-03-14 14:31:03 +01:00
|
|
|
|
|
|
|
- name: Verify Format
|
2022-06-24 16:39:34 +02:00
|
|
|
run: dotnet format --verify-no-changes
|
2022-03-14 14:31:03 +01:00
|
|
|
|
2021-05-04 22:41:49 +02:00
|
|
|
testing:
|
2021-05-27 16:32:36 +02:00
|
|
|
name: Testing
|
2023-01-30 11:07:20 +01:00
|
|
|
runs-on: ubuntu-22.04
|
2022-02-10 15:40:31 +01:00
|
|
|
env:
|
|
|
|
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
|
2021-05-04 22:41:49 +02:00
|
|
|
steps:
|
2022-06-24 16:39:34 +02:00
|
|
|
- name: Set up dotnet
|
2023-07-03 18:46:36 +02:00
|
|
|
uses: actions/setup-dotnet@3447fd6a9f9e57506b15f895c5b76d3b197dc7c2 # v3.2.0
|
2021-05-04 22:41:49 +02:00
|
|
|
with:
|
2022-10-04 23:23:43 +02:00
|
|
|
dotnet-version: "6.0.x"
|
2021-05-04 22:41:49 +02:00
|
|
|
|
|
|
|
- name: Print environment
|
|
|
|
run: |
|
|
|
|
dotnet --info
|
2022-06-24 16:39:34 +02:00
|
|
|
nuget help | grep Version
|
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
|
2023-07-03 18:36:42 +02:00
|
|
|
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
|
2022-02-10 15:40:31 +01:00
|
|
|
|
2021-05-04 22:41:49 +02:00
|
|
|
- name: Restore
|
2022-06-24 16:39:34 +02:00
|
|
|
run: dotnet restore --locked-mode
|
2021-05-04 22:41:49 +02:00
|
|
|
shell: pwsh
|
2022-08-24 10:45:33 +02:00
|
|
|
|
2023-01-30 11:07:20 +01:00
|
|
|
- name: Remove SQL proj
|
|
|
|
run: dotnet sln bitwarden-server.sln remove src/Sql/Sql.sqlproj
|
|
|
|
|
2022-08-24 10:45:33 +02:00
|
|
|
- name: Build OSS solution
|
2023-01-30 11:07:20 +01:00
|
|
|
run: dotnet build bitwarden-server.sln -p:Configuration=Debug -p:DefineConstants="OSS" --verbosity minimal
|
2022-08-24 10:45:33 +02:00
|
|
|
shell: pwsh
|
2021-05-04 22:41:49 +02:00
|
|
|
|
|
|
|
- name: Build solution
|
2023-01-30 11:07:20 +01:00
|
|
|
run: dotnet build bitwarden-server.sln -p:Configuration=Debug --verbosity minimal
|
2021-05-04 22:41:49 +02:00
|
|
|
shell: pwsh
|
2021-12-16 17:47:01 +01:00
|
|
|
|
2021-10-05 18:12:05 +02:00
|
|
|
- name: Test OSS solution
|
2023-01-30 11:07:20 +01:00
|
|
|
run: dotnet test ./test --configuration Debug --no-build --logger "trx;LogFileName=oss-test-results.trx"
|
2021-10-05 18:12:05 +02:00
|
|
|
shell: pwsh
|
|
|
|
|
|
|
|
- name: Test Bitwarden solution
|
2023-01-30 11:07:20 +01:00
|
|
|
run: dotnet test ./bitwarden_license/test --configuration Debug --no-build --logger "trx;LogFileName=bw-test-results.trx"
|
2021-05-04 22:41:49 +02:00
|
|
|
shell: pwsh
|
2020-07-17 16:51:32 +02:00
|
|
|
|
2023-01-10 16:58:19 +01:00
|
|
|
- name: Report test results
|
2023-05-03 16:20:12 +02:00
|
|
|
uses: dorny/test-reporter@c9b3d0e2bd2a4e96aaf424dbaa31c46b42318226 # v1.6.0
|
2023-01-10 16:58:19 +01:00
|
|
|
if: always()
|
|
|
|
with:
|
|
|
|
name: Test Results
|
|
|
|
path: "**/*-test-results.trx"
|
|
|
|
reporter: dotnet-trx
|
|
|
|
fail-on-error: true
|
|
|
|
|
2021-09-25 00:04:14 +02:00
|
|
|
build-artifacts:
|
|
|
|
name: Build artifacts
|
2022-11-18 20:39:01 +01:00
|
|
|
runs-on: ubuntu-22.04
|
2022-07-19 15:35:26 +02:00
|
|
|
needs:
|
2022-07-11 23:30:52 +02:00
|
|
|
- testing
|
|
|
|
- lint
|
2021-09-25 00:04:14 +02:00
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
include:
|
2022-11-18 20:39:01 +01:00
|
|
|
- project_name: Admin
|
2021-09-25 00:04:14 +02:00
|
|
|
base_path: ./src
|
2022-03-03 23:53:09 +01:00
|
|
|
node: true
|
2022-11-18 20:39:01 +01:00
|
|
|
- project_name: Api
|
2021-09-25 00:04:14 +02:00
|
|
|
base_path: ./src
|
2022-11-18 20:39:01 +01:00
|
|
|
- project_name: Billing
|
2021-09-25 00:04:14 +02:00
|
|
|
base_path: ./src
|
2022-11-18 20:39:01 +01:00
|
|
|
- project_name: Events
|
2021-09-25 00:04:14 +02:00
|
|
|
base_path: ./src
|
2022-11-18 20:39:01 +01:00
|
|
|
- project_name: EventsProcessor
|
2021-09-25 00:04:14 +02:00
|
|
|
base_path: ./src
|
2022-11-18 20:39:01 +01:00
|
|
|
- project_name: Icons
|
2021-09-25 00:04:14 +02:00
|
|
|
base_path: ./src
|
2022-11-18 20:39:01 +01:00
|
|
|
- project_name: Identity
|
2021-09-25 00:04:14 +02:00
|
|
|
base_path: ./src
|
2022-11-18 20:39:01 +01:00
|
|
|
- project_name: Notifications
|
2021-09-25 00:04:14 +02:00
|
|
|
base_path: ./src
|
2022-11-18 20:39:01 +01:00
|
|
|
- project_name: Server
|
2021-09-25 00:04:14 +02:00
|
|
|
base_path: ./util
|
2022-11-18 20:39:01 +01:00
|
|
|
- project_name: Setup
|
2021-09-25 00:04:14 +02:00
|
|
|
base_path: ./util
|
2022-11-18 20:39:01 +01:00
|
|
|
- project_name: Sso
|
2021-09-25 00:04:14 +02:00
|
|
|
base_path: ./bitwarden_license/src
|
2022-03-03 23:53:09 +01:00
|
|
|
node: true
|
2022-11-18 20:39:01 +01:00
|
|
|
- project_name: Scim
|
2022-07-19 15:35:26 +02:00
|
|
|
base_path: ./bitwarden_license/src
|
|
|
|
dotnet: true
|
2023-05-16 17:31:02 +02:00
|
|
|
- project_name: MsSqlMigratorUtility
|
|
|
|
base_path: ./util
|
|
|
|
dotnet: true
|
2021-09-25 00:04:14 +02:00
|
|
|
steps:
|
|
|
|
- name: Checkout repo
|
2023-07-03 18:36:42 +02:00
|
|
|
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
|
2021-09-25 00:04:14 +02:00
|
|
|
|
|
|
|
- name: Set up Node
|
2023-07-03 18:36:42 +02:00
|
|
|
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
|
2021-09-25 00:04:14 +02:00
|
|
|
with:
|
2022-10-04 23:23:43 +02:00
|
|
|
cache: "npm"
|
|
|
|
cache-dependency-path: "**/package-lock.json"
|
|
|
|
node-version: "16"
|
2021-09-25 00:04:14 +02:00
|
|
|
|
|
|
|
- name: Print environment
|
|
|
|
run: |
|
|
|
|
whoami
|
|
|
|
dotnet --info
|
|
|
|
node --version
|
|
|
|
npm --version
|
|
|
|
echo "GitHub ref: $GITHUB_REF"
|
|
|
|
echo "GitHub event: $GITHUB_EVENT"
|
|
|
|
|
2022-11-18 20:39:01 +01:00
|
|
|
- name: Restore/Clean project
|
|
|
|
working-directory: ${{ matrix.base_path }}/${{ matrix.project_name }}
|
2021-09-25 00:04:14 +02:00
|
|
|
run: |
|
|
|
|
echo "Restore"
|
|
|
|
dotnet restore
|
|
|
|
echo "Clean"
|
|
|
|
dotnet clean -c "Release" -o obj/build-output/publish
|
|
|
|
|
2022-03-03 23:53:09 +01:00
|
|
|
- name: Build node
|
|
|
|
if: ${{ matrix.node }}
|
2022-11-18 20:39:01 +01:00
|
|
|
working-directory: ${{ matrix.base_path }}/${{ matrix.project_name }}
|
2021-09-25 00:04:14 +02:00
|
|
|
run: |
|
2022-03-03 23:53:09 +01:00
|
|
|
npm ci
|
|
|
|
npm run build
|
2021-09-25 00:04:14 +02:00
|
|
|
|
2022-11-18 20:39:01 +01:00
|
|
|
- name: Publish project
|
|
|
|
working-directory: ${{ matrix.base_path }}/${{ matrix.project_name }}
|
2021-09-25 00:04:14 +02:00
|
|
|
run: |
|
|
|
|
echo "Publish"
|
|
|
|
dotnet publish -c "Release" -o obj/build-output/publish
|
|
|
|
|
|
|
|
cd obj/build-output/publish
|
2022-11-18 20:39:01 +01:00
|
|
|
zip -r ${{ matrix.project_name }}.zip .
|
|
|
|
mv ${{ matrix.project_name }}.zip ../../../
|
2021-09-25 00:04:14 +02:00
|
|
|
|
|
|
|
pwd
|
|
|
|
ls -atlh ../../../
|
|
|
|
|
2022-11-18 20:39:01 +01:00
|
|
|
- name: Upload project artifact
|
2023-07-03 18:36:42 +02:00
|
|
|
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
|
2021-09-25 00:04:14 +02:00
|
|
|
with:
|
2022-11-18 20:39:01 +01:00
|
|
|
name: ${{ matrix.project_name }}.zip
|
|
|
|
path: ${{ matrix.base_path }}/${{ matrix.project_name }}/${{ matrix.project_name }}.zip
|
2021-09-25 00:04:14 +02:00
|
|
|
if-no-files-found: error
|
|
|
|
|
|
|
|
build-docker:
|
|
|
|
name: Build Docker images
|
2022-11-18 20:39:01 +01:00
|
|
|
runs-on: ubuntu-22.04
|
2021-09-25 00:04:14 +02:00
|
|
|
needs: build-artifacts
|
2021-05-27 16:32:36 +02:00
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
include:
|
2022-11-18 20:39:01 +01:00
|
|
|
- project_name: Admin
|
2021-05-27 16:32:36 +02:00
|
|
|
base_path: ./src
|
2023-02-16 23:16:32 +01:00
|
|
|
docker_repos: [bitwarden, bitwardenprod.azurecr.io, bitwardenqa.azurecr.io]
|
2021-05-27 16:32:36 +02:00
|
|
|
dotnet: true
|
2022-11-18 20:39:01 +01:00
|
|
|
- project_name: Api
|
2021-05-27 16:32:36 +02:00
|
|
|
base_path: ./src
|
2023-02-16 23:16:32 +01:00
|
|
|
docker_repos: [bitwarden, bitwardenprod.azurecr.io, bitwardenqa.azurecr.io]
|
2021-05-27 16:32:36 +02:00
|
|
|
dotnet: true
|
2022-11-18 20:39:01 +01:00
|
|
|
- project_name: Attachments
|
2021-05-27 16:32:36 +02:00
|
|
|
base_path: ./util
|
2023-02-16 23:16:32 +01:00
|
|
|
docker_repos: [bitwarden, bitwardenprod.azurecr.io, bitwardenqa.azurecr.io]
|
2022-11-18 20:39:01 +01:00
|
|
|
- project_name: Events
|
2021-05-27 16:32:36 +02:00
|
|
|
base_path: ./src
|
2023-02-16 23:16:32 +01:00
|
|
|
docker_repos: [bitwarden, bitwardenprod.azurecr.io, bitwardenqa.azurecr.io]
|
2021-06-14 20:11:05 +02:00
|
|
|
dotnet: true
|
2022-11-18 20:39:01 +01:00
|
|
|
- project_name: EventsProcessor
|
2021-06-14 20:11:05 +02:00
|
|
|
base_path: ./src
|
2023-02-16 23:16:32 +01:00
|
|
|
docker_repos: [bitwardenprod.azurecr.io, bitwardenqa.azurecr.io]
|
2021-05-27 16:32:36 +02:00
|
|
|
dotnet: true
|
2022-11-18 20:39:01 +01:00
|
|
|
- project_name: Icons
|
2021-05-27 16:32:36 +02:00
|
|
|
base_path: ./src
|
2023-02-16 23:16:32 +01:00
|
|
|
docker_repos: [bitwarden, bitwardenprod.azurecr.io, bitwardenqa.azurecr.io]
|
2021-05-27 16:32:36 +02:00
|
|
|
dotnet: true
|
2022-11-18 20:39:01 +01:00
|
|
|
- project_name: Identity
|
2021-05-27 16:32:36 +02:00
|
|
|
base_path: ./src
|
2023-02-16 23:16:32 +01:00
|
|
|
docker_repos: [bitwarden, bitwardenprod.azurecr.io, bitwardenqa.azurecr.io]
|
2021-05-27 16:32:36 +02:00
|
|
|
dotnet: true
|
2022-11-18 20:39:01 +01:00
|
|
|
- project_name: MsSql
|
2021-05-27 16:32:36 +02:00
|
|
|
base_path: ./util
|
2023-02-16 23:16:32 +01:00
|
|
|
docker_repos: [bitwarden, bitwardenprod.azurecr.io, bitwardenqa.azurecr.io]
|
2022-11-18 20:39:01 +01:00
|
|
|
- project_name: Nginx
|
2021-05-27 16:32:36 +02:00
|
|
|
base_path: ./util
|
2023-02-16 23:16:32 +01:00
|
|
|
docker_repos: [bitwarden, bitwardenprod.azurecr.io, bitwardenqa.azurecr.io]
|
2022-11-18 20:39:01 +01:00
|
|
|
- project_name: Notifications
|
2021-05-27 16:32:36 +02:00
|
|
|
base_path: ./src
|
2023-02-16 23:16:32 +01:00
|
|
|
docker_repos: [bitwarden, bitwardenprod.azurecr.io, bitwardenqa.azurecr.io]
|
2021-05-27 16:32:36 +02:00
|
|
|
dotnet: true
|
2022-11-18 20:39:01 +01:00
|
|
|
- project_name: Server
|
2021-05-27 16:32:36 +02:00
|
|
|
base_path: ./util
|
2023-02-16 23:16:32 +01:00
|
|
|
docker_repos: [bitwarden, bitwardenprod.azurecr.io, bitwardenqa.azurecr.io]
|
2021-05-27 16:32:36 +02:00
|
|
|
dotnet: true
|
2022-11-18 20:39:01 +01:00
|
|
|
- project_name: Setup
|
2021-05-27 16:32:36 +02:00
|
|
|
base_path: ./util
|
2023-02-16 23:16:32 +01:00
|
|
|
docker_repos: [bitwarden, bitwardenprod.azurecr.io, bitwardenqa.azurecr.io]
|
2021-05-27 16:32:36 +02:00
|
|
|
dotnet: true
|
2022-11-18 20:39:01 +01:00
|
|
|
- project_name: Sso
|
2021-05-27 16:32:36 +02:00
|
|
|
base_path: ./bitwarden_license/src
|
2023-02-16 23:16:32 +01:00
|
|
|
docker_repos: [bitwarden, bitwardenprod.azurecr.io, bitwardenqa.azurecr.io]
|
2021-05-27 16:32:36 +02:00
|
|
|
dotnet: true
|
2022-11-18 20:39:01 +01:00
|
|
|
- project_name: Scim
|
2022-07-19 15:35:26 +02:00
|
|
|
base_path: ./bitwarden_license/src
|
2023-02-16 23:16:32 +01:00
|
|
|
docker_repos: [bitwarden, bitwardenprod.azurecr.io, bitwardenqa.azurecr.io]
|
2022-07-19 15:35:26 +02:00
|
|
|
dotnet: true
|
2022-12-20 12:09:17 +01:00
|
|
|
- project_name: Billing
|
|
|
|
base_path: ./src
|
2023-02-16 23:16:32 +01:00
|
|
|
docker_repos: [bitwardenprod.azurecr.io, bitwardenqa.azurecr.io]
|
2022-12-20 12:09:17 +01:00
|
|
|
dotnet: true
|
2023-05-16 17:31:02 +02:00
|
|
|
- project_name: MsSqlMigratorUtility
|
|
|
|
base_path: ./util
|
|
|
|
docker_repos: [bitwardenprod.azurecr.io, bitwardenqa.azurecr.io]
|
|
|
|
dotnet: true
|
2020-07-17 16:51:32 +02:00
|
|
|
steps:
|
2021-05-27 16:32:36 +02:00
|
|
|
- name: Checkout repo
|
2023-07-03 18:36:42 +02:00
|
|
|
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
|
2023-02-15 11:45:46 +01:00
|
|
|
|
2023-02-16 23:16:32 +01:00
|
|
|
- name: Check Branch to Publish
|
|
|
|
env:
|
|
|
|
PUBLISH_BRANCHES: "master,rc,hotfix-rc"
|
|
|
|
id: publish-branch-check
|
2023-01-30 22:12:09 +01:00
|
|
|
run: |
|
2023-02-16 23:16:32 +01:00
|
|
|
IFS="," read -a publish_branches <<< $PUBLISH_BRANCHES
|
2021-05-27 16:32:36 +02:00
|
|
|
|
2023-02-16 23:16:32 +01:00
|
|
|
if [[ " ${publish_branches[*]} " =~ " ${GITHUB_REF:11} " ]]; then
|
|
|
|
echo "is_publish_branch=true" >> $GITHUB_ENV
|
|
|
|
else
|
|
|
|
echo "is_publish_branch=false" >> $GITHUB_ENV
|
|
|
|
fi
|
2021-06-14 20:11:05 +02:00
|
|
|
|
2023-02-16 23:16:32 +01:00
|
|
|
########## ACRs ##########
|
|
|
|
- name: Login to Azure - QA Subscription
|
2023-07-03 18:36:42 +02:00
|
|
|
uses: Azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 # v1.4.7
|
2021-09-25 00:04:14 +02:00
|
|
|
with:
|
2023-02-16 23:16:32 +01:00
|
|
|
creds: ${{ secrets.AZURE_QA_KV_CREDENTIALS }}
|
2021-10-06 19:21:35 +02:00
|
|
|
|
2023-02-16 23:16:32 +01:00
|
|
|
- name: Login to QA ACR
|
|
|
|
run: az acr login -n bitwardenqa
|
2021-05-27 16:32:36 +02:00
|
|
|
|
2023-01-30 22:12:09 +01:00
|
|
|
- name: Login to Azure - PROD Subscription
|
2023-07-03 18:36:42 +02:00
|
|
|
uses: Azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 # v1.4.7
|
2023-01-30 22:12:09 +01:00
|
|
|
with:
|
|
|
|
creds: ${{ secrets.AZURE_PROD_KV_CREDENTIALS }}
|
|
|
|
|
|
|
|
- name: Login to PROD ACR
|
|
|
|
run: az acr login -n bitwardenprod
|
|
|
|
|
2023-04-17 15:06:57 +02:00
|
|
|
- name: Login to Azure - CI Subscription
|
2023-07-03 18:36:42 +02:00
|
|
|
uses: Azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 # v1.4.7
|
2023-04-17 15:06:57 +02:00
|
|
|
with:
|
2023-04-17 19:03:32 +02:00
|
|
|
creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }}
|
2023-04-17 15:06:57 +02:00
|
|
|
|
2023-02-16 23:16:32 +01:00
|
|
|
- name: Retrieve github PAT secrets
|
|
|
|
id: retrieve-secret-pat
|
2023-06-29 23:39:50 +02:00
|
|
|
uses: bitwarden/gh-actions/get-keyvault-secrets@74f4ac01c9abe0a7331c9a5de822a558fd4a4710
|
2022-01-24 20:12:37 +01:00
|
|
|
with:
|
2023-04-17 15:06:57 +02:00
|
|
|
keyvault: "bitwarden-ci"
|
2023-02-16 23:16:32 +01:00
|
|
|
secrets: "github-pat-bitwarden-devops-bot-repo-scope"
|
2022-01-24 20:12:37 +01:00
|
|
|
|
|
|
|
- name: Retrieve secrets
|
2023-02-16 23:16:32 +01:00
|
|
|
if: ${{ env.is_publish_branch == 'true' }}
|
2022-01-24 20:12:37 +01:00
|
|
|
id: retrieve-secrets
|
2023-06-29 23:39:50 +02:00
|
|
|
uses: bitwarden/gh-actions/get-keyvault-secrets@74f4ac01c9abe0a7331c9a5de822a558fd4a4710
|
2022-10-04 20:23:08 +02:00
|
|
|
with:
|
2023-04-17 15:06:57 +02:00
|
|
|
keyvault: "bitwarden-ci"
|
2022-10-04 20:23:08 +02:00
|
|
|
secrets: "docker-password,
|
2022-10-04 23:23:43 +02:00
|
|
|
docker-username,
|
|
|
|
dct-delegate-2-repo-passphrase,
|
|
|
|
dct-delegate-2-key"
|
2022-01-24 20:12:37 +01:00
|
|
|
|
|
|
|
- name: Log into Docker
|
2023-02-16 23:16:32 +01:00
|
|
|
if: ${{ env.is_publish_branch == 'true' }}
|
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
|
|
|
|
2023-06-23 19:12:54 +02:00
|
|
|
- name: Setup Docker Content Trust (DCT)
|
2023-02-16 23:16:32 +01:00
|
|
|
if: ${{ env.is_publish_branch == 'true' }}
|
2023-06-29 23:39:50 +02:00
|
|
|
uses: bitwarden/gh-actions/setup-docker-trust@74f4ac01c9abe0a7331c9a5de822a558fd4a4710
|
2023-06-23 19:12:54 +02:00
|
|
|
with:
|
|
|
|
azure-creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }}
|
|
|
|
azure-keyvault-name: "bitwarden-ci"
|
2022-01-24 20:12:37 +01:00
|
|
|
|
2023-02-16 23:16:32 +01:00
|
|
|
########## Generate image tag and build Docker image ##########
|
|
|
|
- name: Generate Docker image tag
|
|
|
|
id: tag
|
|
|
|
run: |
|
|
|
|
IMAGE_TAG=$(echo "${GITHUB_REF:11}" | sed "s#/#-#g") # slash safe branch name
|
|
|
|
if [[ "$IMAGE_TAG" == "master" ]]; then
|
|
|
|
IMAGE_TAG=dev
|
|
|
|
fi
|
|
|
|
echo "image_tag=$IMAGE_TAG" >> $GITHUB_OUTPUT
|
|
|
|
|
|
|
|
- name: Setup project name
|
|
|
|
id: setup
|
|
|
|
run: |
|
|
|
|
PROJECT_NAME=$(echo "${{ matrix.project_name }}" | awk '{print tolower($0)}')
|
|
|
|
echo "Matrix name: ${{ matrix.project_name }}"
|
|
|
|
echo "PROJECT_NAME: $PROJECT_NAME"
|
|
|
|
echo "project_name=$PROJECT_NAME" >> $GITHUB_OUTPUT
|
|
|
|
|
|
|
|
- name: Generate tag list
|
|
|
|
id: tag-list
|
2022-01-24 21:42:14 +01:00
|
|
|
env:
|
2023-02-16 23:16:32 +01:00
|
|
|
IMAGE_TAG: ${{ steps.tag.outputs.image_tag }}
|
2022-11-18 20:39:01 +01:00
|
|
|
PROJECT_NAME: ${{ steps.setup.outputs.project_name }}
|
2023-02-17 00:14:39 +01:00
|
|
|
run: echo "tags=bitwardenqa.azurecr.io/${PROJECT_NAME}:${IMAGE_TAG},bitwardenprod.azurecr.io/${PROJECT_NAME}:${IMAGE_TAG}" >> $GITHUB_OUTPUT
|
2023-02-16 23:16:32 +01:00
|
|
|
|
|
|
|
- name: Get build artifact
|
|
|
|
if: ${{ matrix.dotnet }}
|
2023-07-03 18:36:42 +02:00
|
|
|
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
|
2023-02-16 23:16:32 +01:00
|
|
|
with:
|
|
|
|
name: ${{ matrix.project_name }}.zip
|
|
|
|
|
|
|
|
- name: Setup build artifact
|
|
|
|
if: ${{ matrix.dotnet }}
|
|
|
|
run: |
|
|
|
|
mkdir -p ${{ matrix.base_path}}/${{ matrix.project_name }}/obj/build-output/publish
|
|
|
|
unzip ${{ matrix.project_name }}.zip \
|
|
|
|
-d ${{ matrix.base_path }}/${{ matrix.project_name }}/obj/build-output/publish
|
|
|
|
|
|
|
|
- name: Build Docker image
|
2023-07-03 18:36:42 +02:00
|
|
|
uses: docker/build-push-action@1104d471370f9806843c095c1db02b5a90c5f8b6 # v3.3.1
|
2023-02-16 23:16:32 +01:00
|
|
|
with:
|
|
|
|
context: ${{ matrix.base_path }}/${{ matrix.project_name }}
|
|
|
|
file: ${{ matrix.base_path }}/${{ matrix.project_name }}/Dockerfile
|
|
|
|
platforms: linux/amd64
|
|
|
|
push: true
|
|
|
|
tags: ${{ steps.tag-list.outputs.tags }}
|
|
|
|
secrets: |
|
|
|
|
"GH_PAT=${{ steps.retrieve-secret-pat.outputs.github-pat-bitwarden-devops-bot-repo-scope }}"
|
|
|
|
|
2023-02-17 00:14:39 +01:00
|
|
|
- name: Push to DockerHub
|
|
|
|
if: contains(matrix.docker_repos, 'bitwarden') && env.is_publish_branch == 'true'
|
|
|
|
env:
|
|
|
|
IMAGE_TAG: ${{ steps.tag.outputs.image_tag }}
|
2023-02-17 00:32:48 +01:00
|
|
|
PROJECT_NAME: ${{ steps.setup.outputs.project_name }}
|
2023-02-17 00:14:39 +01:00
|
|
|
run: |
|
2023-02-17 00:32:48 +01:00
|
|
|
docker tag bitwardenprod.azurecr.io/$PROJECT_NAME:$IMAGE_TAG bitwarden/$PROJECT_NAME:$IMAGE_TAG
|
|
|
|
docker push bitwarden/$PROJECT_NAME:$IMAGE_TAG
|
2023-02-17 00:14:39 +01:00
|
|
|
|
2023-02-16 23:16:32 +01:00
|
|
|
- name: Log out of Docker
|
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-05-27 16:32:36 +02:00
|
|
|
upload:
|
|
|
|
name: Upload
|
2022-11-18 20:39:01 +01:00
|
|
|
runs-on: ubuntu-22.04
|
2021-09-25 00:04:14 +02:00
|
|
|
needs: build-docker
|
2021-05-27 16:32:36 +02:00
|
|
|
steps:
|
2023-01-24 18:10:00 +01:00
|
|
|
- name: Set up dotnet
|
2023-07-03 18:36:42 +02:00
|
|
|
uses: actions/setup-dotnet@3447fd6a9f9e57506b15f895c5b76d3b197dc7c2 # v3.2.0
|
2023-01-24 18:10:00 +01:00
|
|
|
with:
|
|
|
|
dotnet-version: "6.0.x"
|
|
|
|
|
2021-05-27 16:32:36 +02:00
|
|
|
- name: Checkout repo
|
2023-07-03 18:36:42 +02:00
|
|
|
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
|
2021-05-27 16:32:36 +02:00
|
|
|
|
|
|
|
- name: Restore
|
|
|
|
run: dotnet tool restore
|
|
|
|
|
|
|
|
- name: Make Docker stub
|
2022-03-16 16:18:35 +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 ..
|
|
|
|
|
2022-02-28 15:38:59 +01:00
|
|
|
- name: Make Docker stub checksum
|
|
|
|
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/rc' || github.ref == 'refs/heads/hotfix-rc'
|
|
|
|
run: sha256sum docker-stub.zip > docker-stub-sha256.txt
|
|
|
|
|
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'
|
2023-07-03 18:36:42 +02:00
|
|
|
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
|
2020-07-17 16:51:32 +02:00
|
|
|
with:
|
|
|
|
name: docker-stub.zip
|
2022-02-28 15:38:59 +01:00
|
|
|
path: docker-stub.zip
|
|
|
|
if-no-files-found: error
|
|
|
|
|
|
|
|
- name: Upload Docker stub checksum artifact
|
|
|
|
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/rc' || github.ref == 'refs/heads/hotfix-rc'
|
2023-07-03 18:36:42 +02:00
|
|
|
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
|
2022-02-28 15:38:59 +01:00
|
|
|
with:
|
|
|
|
name: docker-stub-sha256.txt
|
|
|
|
path: docker-stub-sha256.txt
|
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
|
2022-10-04 23:23:43 +02:00
|
|
|
swaggerGen: "True"
|
2022-02-23 19:29:17 +01:00
|
|
|
DOTNET_ROLL_FORWARD_ON_NO_CANDIDATE_FX: 2
|
2023-01-13 15:02:53 +01:00
|
|
|
GLOBALSETTINGS__SQLSERVER__CONNECTIONSTRING: "placeholder"
|
2020-07-17 17:19:00 +02:00
|
|
|
|
2021-05-27 16:32:36 +02:00
|
|
|
- name: Upload Swagger artifact
|
2023-07-03 18:36:42 +02:00
|
|
|
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
|
2020-07-17 17:19:00 +02:00
|
|
|
with:
|
|
|
|
name: swagger.json
|
2022-02-28 15:38:59 +01:00
|
|
|
path: swagger.json
|
2021-07-02 22:34:20 +02:00
|
|
|
if-no-files-found: error
|
2021-10-13 21:50:40 +02:00
|
|
|
|
2023-03-07 14:10:34 +01:00
|
|
|
build-mssqlmigratorutility:
|
|
|
|
name: Build MsSqlMigratorUtility
|
|
|
|
runs-on: ubuntu-22.04
|
|
|
|
needs:
|
|
|
|
- lint
|
|
|
|
defaults:
|
|
|
|
run:
|
|
|
|
shell: bash
|
|
|
|
working-directory: "util/MsSqlMigratorUtility"
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
target:
|
|
|
|
- osx-x64
|
|
|
|
- linux-x64
|
|
|
|
- win-x64
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Checkout repo
|
2023-07-03 18:36:42 +02:00
|
|
|
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
|
2023-03-07 14:10:34 +01:00
|
|
|
|
|
|
|
- name: Print environment
|
|
|
|
run: |
|
|
|
|
whoami
|
|
|
|
dotnet --info
|
|
|
|
echo "GitHub ref: $GITHUB_REF"
|
|
|
|
echo "GitHub event: $GITHUB_EVENT"
|
|
|
|
|
|
|
|
- name: Restore project
|
|
|
|
run: |
|
|
|
|
echo "Restore"
|
|
|
|
dotnet restore
|
|
|
|
|
|
|
|
- name: Publish project
|
2023-03-15 16:57:36 +01:00
|
|
|
run: dotnet publish -c "Release" -o obj/build-output/publish -r ${{ matrix.target }} -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true --self-contained true
|
2023-03-07 14:10:34 +01:00
|
|
|
|
|
|
|
- name: Upload project artifact Windows
|
|
|
|
if: ${{ contains(matrix.target, 'win') == true }}
|
2023-07-03 18:36:42 +02:00
|
|
|
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
|
2023-03-07 14:10:34 +01:00
|
|
|
with:
|
|
|
|
name: MsSqlMigratorUtility-${{ matrix.target }}
|
|
|
|
path: util/MsSqlMigratorUtility/obj/build-output/publish/MsSqlMigratorUtility.exe
|
|
|
|
if-no-files-found: error
|
|
|
|
|
|
|
|
- name: Upload project artifact
|
|
|
|
if: ${{ contains(matrix.target, 'win') == false }}
|
2023-07-03 18:36:42 +02:00
|
|
|
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
|
2023-03-07 14:10:34 +01:00
|
|
|
with:
|
|
|
|
name: MsSqlMigratorUtility-${{ matrix.target }}
|
|
|
|
path: util/MsSqlMigratorUtility/obj/build-output/publish/MsSqlMigratorUtility
|
|
|
|
if-no-files-found: error
|
|
|
|
|
2023-06-27 19:18:51 +02:00
|
|
|
self-host-build:
|
|
|
|
name: Self-host build
|
|
|
|
needs: build-docker
|
|
|
|
uses: bitwarden/self-host/.github/workflows/build-unified.yml@master
|
|
|
|
with:
|
|
|
|
server_branch: ${{ github.ref_name }}
|
|
|
|
secrets: inherit
|
2023-06-23 09:23:47 +02:00
|
|
|
|
2021-10-13 21:50:40 +02:00
|
|
|
check-failures:
|
|
|
|
name: Check for failures
|
|
|
|
if: always()
|
2022-11-18 20:39:01 +01:00
|
|
|
runs-on: ubuntu-22.04
|
2021-10-13 21:50:40 +02:00
|
|
|
needs:
|
|
|
|
- cloc
|
2022-03-14 14:31:03 +01:00
|
|
|
- lint
|
2021-10-13 21:50:40 +02:00
|
|
|
- testing
|
|
|
|
- build-artifacts
|
|
|
|
- build-docker
|
|
|
|
- upload
|
2023-03-07 14:10:34 +01:00
|
|
|
- build-mssqlmigratorutility
|
2023-06-27 19:18:51 +02:00
|
|
|
- self-host-build
|
2021-10-13 21:50:40 +02:00
|
|
|
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 }}
|
2022-03-14 14:31:03 +01:00
|
|
|
LINT_STATUS: ${{ needs.lint.result }}
|
2021-10-13 21:50:40 +02:00
|
|
|
TESTING_STATUS: ${{ needs.testing.result }}
|
|
|
|
BUILD_ARTIFACTS_STATUS: ${{ needs.build-artifacts.result }}
|
|
|
|
BUILD_DOCKER_STATUS: ${{ needs.build-docker.result }}
|
|
|
|
UPLOAD_STATUS: ${{ needs.upload.result }}
|
2023-03-07 14:10:34 +01:00
|
|
|
BUILD_MSSQLMIGRATORUTILITY_STATUS: ${{ needs.build-mssqlmigratorutility.result }}
|
2023-06-27 19:18:51 +02:00
|
|
|
TRIGGER_SELF_HOST_BUILD_STATUS: ${{ needs.self-host-build.result }}
|
2021-10-13 21:50:40 +02:00
|
|
|
run: |
|
|
|
|
if [ "$CLOC_STATUS" = "failure" ]; then
|
|
|
|
exit 1
|
2022-03-14 14:31:03 +01:00
|
|
|
elif [ "$LINT_STATUS" = "failure" ]; then
|
|
|
|
exit 1
|
2021-10-13 21:50:40 +02:00
|
|
|
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
|
2023-03-07 14:10:34 +01:00
|
|
|
elif [ "$BUILD_MSSQLMIGRATORUTILITY_STATUS" = "failure" ]; then
|
|
|
|
exit 1
|
2023-06-23 16:54:41 +02:00
|
|
|
elif [ "$TRIGGER_SELF_HOST_BUILD_STATUS" = "failure" ]; then
|
|
|
|
exit 1
|
2021-10-13 21:50:40 +02:00
|
|
|
fi
|
|
|
|
|
2023-04-17 19:03:32 +02:00
|
|
|
- name: Login to Azure - CI subscription
|
2023-07-03 18:36:42 +02:00
|
|
|
uses: Azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 # v1.4.7
|
2021-10-13 21:50:40 +02:00
|
|
|
if: failure()
|
|
|
|
with:
|
2023-04-17 19:03:32 +02:00
|
|
|
creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }}
|
2021-10-13 21:50:40 +02:00
|
|
|
|
2022-10-04 20:23:08 +02:00
|
|
|
- name: Retrieve secrets
|
2021-10-13 21:50:40 +02:00
|
|
|
id: retrieve-secrets
|
2023-06-29 23:39:50 +02:00
|
|
|
uses: bitwarden/gh-actions/get-keyvault-secrets@74f4ac01c9abe0a7331c9a5de822a558fd4a4710
|
2021-10-13 21:50:40 +02:00
|
|
|
if: failure()
|
2022-10-04 20:23:08 +02:00
|
|
|
with:
|
2023-04-17 15:06:57 +02:00
|
|
|
keyvault: "bitwarden-ci"
|
2022-10-04 20:23:08 +02:00
|
|
|
secrets: "devops-alerts-slack-webhook-url"
|
2021-10-13 21:50:40 +02:00
|
|
|
|
|
|
|
- name: Notify Slack on failure
|
2023-05-03 16:20:12 +02:00
|
|
|
uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f # v2.0.0
|
2021-10-13 21:50:40 +02:00
|
|
|
if: failure()
|
|
|
|
env:
|
|
|
|
SLACK_WEBHOOK_URL: ${{ steps.retrieve-secrets.outputs.devops-alerts-slack-webhook-url }}
|
|
|
|
with:
|
|
|
|
status: ${{ job.status }}
|