2021-09-02 22:05:17 +02:00
|
|
|
---
|
2021-06-14 21:20:49 +02:00
|
|
|
name: Build
|
2020-12-21 18:46:36 +01:00
|
|
|
|
|
|
|
on:
|
2021-08-10 16:28:21 +02:00
|
|
|
workflow_dispatch:
|
|
|
|
inputs:
|
|
|
|
custom_tag_extension:
|
|
|
|
description: "Custom image tag extension"
|
|
|
|
required: false
|
2020-12-21 18:46:36 +01:00
|
|
|
push:
|
|
|
|
branches-ignore:
|
|
|
|
- 'l10n_master'
|
|
|
|
- 'gh-pages'
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
cloc:
|
2021-06-14 21:20:49 +02:00
|
|
|
name: CLOC
|
2020-12-21 18:46:36 +01:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout repo
|
2021-05-17 17:18:45 +02:00
|
|
|
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
|
2020-12-21 18:46:36 +01:00
|
|
|
|
|
|
|
- name: Set up cloc
|
|
|
|
run: |
|
|
|
|
sudo apt update
|
|
|
|
sudo apt -y install cloc
|
|
|
|
|
|
|
|
- name: Print lines of code
|
|
|
|
run: cloc --include-lang TypeScript,JavaScript,HTML,Sass,CSS --vcs git
|
|
|
|
|
2021-06-14 21:20:49 +02:00
|
|
|
|
|
|
|
build-selfhost:
|
|
|
|
name: Build SelfHost Docker image
|
2020-12-21 18:46:36 +01:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Set up Node
|
2021-05-17 17:18:45 +02:00
|
|
|
uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea
|
2020-12-21 18:46:36 +01:00
|
|
|
with:
|
2021-05-17 17:18:45 +02:00
|
|
|
node-version: '14'
|
2020-12-21 18:46:36 +01:00
|
|
|
|
2021-05-26 22:17:37 +02:00
|
|
|
- name: Update NPM
|
|
|
|
run: |
|
|
|
|
npm install -g npm@7
|
|
|
|
|
2021-06-14 21:20:49 +02:00
|
|
|
- name: Cache npm
|
|
|
|
id: npm-cache
|
2021-09-02 22:05:17 +02:00
|
|
|
uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6
|
2021-06-14 21:20:49 +02:00
|
|
|
with:
|
|
|
|
path: '~/.npm'
|
|
|
|
key: ${{ runner.os }}-${{ github.run_id }}-npm-${{ hashFiles('**/package-lock.json') }}
|
|
|
|
|
2020-12-21 18:46:36 +01:00
|
|
|
- name: Print environment
|
|
|
|
run: |
|
|
|
|
whoami
|
|
|
|
node --version
|
|
|
|
npm --version
|
|
|
|
gulp --version
|
|
|
|
docker --version
|
|
|
|
echo "GitHub ref: $GITHUB_REF"
|
|
|
|
echo "GitHub event: $GITHUB_EVENT"
|
|
|
|
|
2021-05-11 21:02:31 +02:00
|
|
|
- name: Login to Azure
|
2021-06-02 17:28:56 +02:00
|
|
|
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/rc'
|
2021-05-11 21:02:31 +02:00
|
|
|
uses: Azure/login@77f1b2e3fb80c0e8645114159d17008b8a2e475a
|
|
|
|
with:
|
|
|
|
creds: ${{ secrets.AZURE_PROD_KV_CREDENTIALS }}
|
|
|
|
|
|
|
|
- name: Retrieve secrets
|
2021-06-02 17:28:56 +02:00
|
|
|
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/rc'
|
2021-05-11 21:02:31 +02:00
|
|
|
id: retrieve-secrets
|
|
|
|
uses: Azure/get-keyvault-secrets@80ccd3fafe5662407cc2e55f202ee34bfff8c403
|
|
|
|
with:
|
|
|
|
keyvault: "bitwarden-prod-kv"
|
2021-09-02 22:05:17 +02:00
|
|
|
secrets: "docker-password,
|
2021-05-11 21:02:31 +02:00
|
|
|
docker-username,
|
|
|
|
dct-delegate-2-repo-passphrase,
|
|
|
|
dct-delegate-2-key"
|
|
|
|
|
2021-06-02 17:28:56 +02:00
|
|
|
- name: Log into Docker
|
|
|
|
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/rc'
|
2021-05-11 21:02:31 +02:00
|
|
|
run: echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
|
2020-12-21 18:46:36 +01:00
|
|
|
env:
|
2021-05-11 21:02:31 +02:00
|
|
|
DOCKER_USERNAME: ${{ steps.retrieve-secrets.outputs.docker-username }}
|
|
|
|
DOCKER_PASSWORD: ${{ steps.retrieve-secrets.outputs.docker-password }}
|
2020-12-21 18:46:36 +01:00
|
|
|
|
|
|
|
- name: Setup Docker Trust
|
2021-06-02 17:28:56 +02:00
|
|
|
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/rc'
|
2020-12-21 18:46:36 +01:00
|
|
|
run: |
|
|
|
|
mkdir -p ~/.docker/trust/private
|
|
|
|
|
2021-05-11 21:02:31 +02:00
|
|
|
echo "$DCT_DELEGATE_KEY" > ~/.docker/trust/private/$DCT_DELEGATION_KEY_ID.key
|
2020-12-21 18:46:36 +01:00
|
|
|
env:
|
2021-05-11 21:02:31 +02:00
|
|
|
DCT_DELEGATION_KEY_ID: "c9bde8ec820701516491e5e03d3a6354e7bd66d05fa3df2b0062f68b116dc59c"
|
|
|
|
DCT_DELEGATE_KEY: ${{ steps.retrieve-secrets.outputs.dct-delegate-2-key }}
|
2020-12-21 18:46:36 +01:00
|
|
|
|
|
|
|
- name: Checkout repo
|
2021-05-17 17:18:45 +02:00
|
|
|
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
|
2020-12-21 18:46:36 +01:00
|
|
|
|
|
|
|
- name: Restore
|
|
|
|
run: dotnet tool restore
|
|
|
|
|
2021-06-14 21:20:49 +02:00
|
|
|
- name: Install dependencies
|
|
|
|
run: npm install
|
|
|
|
|
2020-12-21 18:46:36 +01:00
|
|
|
- name: Build
|
|
|
|
run: |
|
2021-04-20 22:27:09 +02:00
|
|
|
echo -e "# Building Web\n"
|
|
|
|
echo "Building app"
|
|
|
|
echo "npm version $(npm --version)"
|
|
|
|
npm run dist:selfhost
|
|
|
|
|
2021-06-02 17:28:56 +02:00
|
|
|
echo -e "\nBuilding Docker image"
|
2021-04-20 22:27:09 +02:00
|
|
|
docker --version
|
|
|
|
docker build -t bitwarden/web .
|
2020-12-21 18:46:36 +01:00
|
|
|
|
2021-03-04 19:07:59 +01:00
|
|
|
- name: Tag rc branch
|
|
|
|
if: github.ref == 'refs/heads/rc'
|
2021-04-20 22:27:09 +02:00
|
|
|
run: docker tag bitwarden/web bitwarden/web:rc
|
2021-03-04 19:07:59 +01:00
|
|
|
|
2020-12-21 18:46:36 +01:00
|
|
|
- name: Tag dev
|
2021-06-02 17:28:56 +02:00
|
|
|
if: github.ref == 'refs/heads/master'
|
2021-04-20 22:27:09 +02:00
|
|
|
run: docker tag bitwarden/web bitwarden/web:dev
|
2020-12-21 18:46:36 +01:00
|
|
|
|
2021-06-02 17:28:56 +02:00
|
|
|
- name: List Docker images
|
|
|
|
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/rc'
|
2020-12-21 18:46:36 +01:00
|
|
|
run: docker images
|
|
|
|
|
2021-03-04 19:07:59 +01:00
|
|
|
- name: Push rc images
|
|
|
|
if: github.ref == 'refs/heads/rc'
|
2021-04-20 22:27:09 +02:00
|
|
|
run: docker push bitwarden/web:rc
|
2021-09-02 22:05:17 +02:00
|
|
|
env:
|
2021-03-04 19:07:59 +01:00
|
|
|
DOCKER_CONTENT_TRUST: 1
|
2021-05-11 21:46:14 +02:00
|
|
|
DOCKER_CONTENT_TRUST_REPOSITORY_PASSPHRASE: ${{ steps.retrieve-secrets.outputs.dct-delegate-2-repo-passphrase }}
|
2021-03-04 19:07:59 +01:00
|
|
|
|
2020-12-21 18:46:36 +01:00
|
|
|
- name: Push dev images
|
2021-06-02 17:28:56 +02:00
|
|
|
if: github.ref == 'refs/heads/master'
|
2021-04-20 22:27:09 +02:00
|
|
|
run: docker push bitwarden/web:dev
|
2021-09-02 22:05:17 +02:00
|
|
|
env:
|
2020-12-21 18:46:36 +01:00
|
|
|
DOCKER_CONTENT_TRUST: 1
|
2021-05-11 21:46:14 +02:00
|
|
|
DOCKER_CONTENT_TRUST_REPOSITORY_PASSPHRASE: ${{ steps.retrieve-secrets.outputs.dct-delegate-2-repo-passphrase }}
|
2020-12-21 18:46:36 +01:00
|
|
|
|
2021-06-02 17:28:56 +02:00
|
|
|
- name: Log out of Docker
|
|
|
|
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/rc'
|
2020-12-21 18:46:36 +01:00
|
|
|
run: docker logout
|
|
|
|
|
2021-06-14 21:20:49 +02:00
|
|
|
|
|
|
|
build-qa:
|
|
|
|
name: Build QA Docker image
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Set up Node
|
|
|
|
uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea
|
|
|
|
with:
|
|
|
|
node-version: '14'
|
|
|
|
|
|
|
|
- name: Update NPM
|
|
|
|
run: |
|
|
|
|
npm install -g npm@7
|
|
|
|
|
|
|
|
- name: Cache npm
|
|
|
|
id: npm-cache
|
2021-09-02 22:05:17 +02:00
|
|
|
uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353 # v2.1.6
|
2021-06-14 21:20:49 +02:00
|
|
|
with:
|
|
|
|
path: '~/.npm'
|
|
|
|
key: ${{ runner.os }}-${{ github.run_id }}-npm-${{ hashFiles('**/package-lock.json') }}
|
|
|
|
|
|
|
|
- name: Print environment
|
|
|
|
run: |
|
|
|
|
whoami
|
|
|
|
node --version
|
|
|
|
npm --version
|
|
|
|
gulp --version
|
|
|
|
docker --version
|
|
|
|
echo "GitHub ref: $GITHUB_REF"
|
|
|
|
echo "GitHub event: $GITHUB_EVENT"
|
|
|
|
|
|
|
|
- name: Login to Azure
|
|
|
|
uses: Azure/login@77f1b2e3fb80c0e8645114159d17008b8a2e475a
|
|
|
|
with:
|
|
|
|
creds: ${{ secrets.AZURE_QA_KV_CREDENTIALS }}
|
|
|
|
|
|
|
|
- name: Log into container registry
|
|
|
|
run: az acr login -n bitwardenqa
|
|
|
|
|
|
|
|
- name: Checkout repo
|
|
|
|
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
|
|
|
|
|
|
|
|
- name: Restore
|
|
|
|
run: dotnet tool restore
|
|
|
|
|
|
|
|
- name: Install dependencies
|
|
|
|
run: npm ci
|
|
|
|
|
|
|
|
- name: Build
|
|
|
|
run: |
|
|
|
|
echo -e "# Building Web\n"
|
|
|
|
echo "Building app"
|
|
|
|
echo "npm version $(npm --version)"
|
2021-09-08 19:08:31 +02:00
|
|
|
VERSION=$( jq -r ".version" package.json)
|
|
|
|
jq --arg version "$VERSION - ${GITHUB_SHA:0:7}" '.version = $version' package.json > package.json.tmp
|
|
|
|
mv package.json.tmp package.json
|
|
|
|
|
2021-06-14 21:20:49 +02:00
|
|
|
npm run build:qa
|
|
|
|
|
2021-09-08 19:08:31 +02:00
|
|
|
echo "{\"commit_hash\": \"$GITHUB_SHA\", \"ref\": \"$GITHUB_REF\"}" | jq . > build/info.json
|
|
|
|
|
2021-06-14 21:20:49 +02:00
|
|
|
echo -e "\nBuilding Docker image"
|
|
|
|
docker --version
|
|
|
|
docker build -t bitwardenqa.azurecr.io/web .
|
|
|
|
|
2021-08-10 16:28:21 +02:00
|
|
|
- name: Get image tag
|
|
|
|
id: image_tag
|
|
|
|
run: |
|
|
|
|
IMAGE_TAG=$(echo "$GITHUB_REF" | awk '{split($0, a, "/"); print a[3];}')
|
|
|
|
TAG_EXTENSION=${{ github.events.inputs.custom_tag_extension }}
|
|
|
|
|
|
|
|
if [[ $TAG_EXTENSION ]]; then
|
|
|
|
IMAGE_TAG=$IMAGE_TAG-$TAG_EXTENSION
|
2021-09-02 22:05:17 +02:00
|
|
|
fi
|
2021-08-10 16:28:21 +02:00
|
|
|
echo "::set-output name=value::$IMAGE_TAG"
|
|
|
|
|
|
|
|
- name: Tag image
|
|
|
|
env:
|
|
|
|
IMAGE_TAG: ${{ steps.image_tag.outputs.value }}
|
|
|
|
run: docker tag bitwardenqa.azurecr.io/web "bitwardenqa.azurecr.io/web:$IMAGE_TAG"
|
2021-06-14 21:20:49 +02:00
|
|
|
|
|
|
|
- name: Tag dev
|
|
|
|
if: github.ref == 'refs/heads/master'
|
|
|
|
run: docker tag bitwardenqa.azurecr.io/web bitwardenqa.azurecr.io/web:dev
|
|
|
|
|
|
|
|
- name: List Docker images
|
|
|
|
run: docker images
|
|
|
|
|
2021-08-10 16:28:21 +02:00
|
|
|
- name: Push image
|
|
|
|
env:
|
|
|
|
IMAGE_TAG: ${{ steps.image_tag.outputs.value }}
|
|
|
|
run: docker push "bitwardenqa.azurecr.io/web:$IMAGE_TAG"
|
2021-06-14 21:20:49 +02:00
|
|
|
|
|
|
|
- name: Push dev images
|
|
|
|
if: github.ref == 'refs/heads/master'
|
|
|
|
run: docker push bitwardenqa.azurecr.io/web:dev
|
|
|
|
|
|
|
|
- name: Log out of Docker
|
|
|
|
run: docker logout
|
|
|
|
|
|
|
|
|
2020-12-21 18:46:36 +01:00
|
|
|
windows:
|
2021-06-14 21:20:49 +02:00
|
|
|
name: Test code on Windows
|
2020-12-21 18:46:36 +01:00
|
|
|
runs-on: windows-latest
|
|
|
|
steps:
|
|
|
|
- name: Set up NuGet
|
2021-05-17 17:18:45 +02:00
|
|
|
uses: nuget/setup-nuget@04b0c2b8d1b97922f67eca497d7cf0bf17b8ffe1
|
2020-12-21 18:46:36 +01:00
|
|
|
with:
|
|
|
|
nuget-version: 'latest'
|
|
|
|
|
|
|
|
- name: Set up MSBuild
|
2021-05-17 17:18:45 +02:00
|
|
|
uses: microsoft/setup-msbuild@c26a08ba26249b81327e26f6ef381897b6a8754d
|
2020-12-21 18:46:36 +01:00
|
|
|
|
|
|
|
- name: Set up Node
|
2021-05-17 17:18:45 +02:00
|
|
|
uses: actions/setup-node@46071b5c7a2e0c34e49c3cb8a0e792e86e18d5ea
|
2020-12-21 18:46:36 +01:00
|
|
|
with:
|
2021-05-17 17:18:45 +02:00
|
|
|
node-version: '14'
|
2020-12-21 18:46:36 +01:00
|
|
|
|
2021-05-26 22:17:37 +02:00
|
|
|
- name: Update NPM
|
|
|
|
run: |
|
|
|
|
npm install -g npm@7
|
|
|
|
|
2020-12-21 18:46:36 +01:00
|
|
|
- name: Print environment
|
|
|
|
run: |
|
2021-05-17 17:18:45 +02:00
|
|
|
nuget help | grep Version
|
2020-12-21 18:46:36 +01:00
|
|
|
msbuild -version
|
|
|
|
dotnet --info
|
|
|
|
node --version
|
|
|
|
npm --version
|
2021-05-17 17:18:45 +02:00
|
|
|
echo "GitHub ref: $GITHUB_REF"
|
|
|
|
echo "GitHub event: $GITHUB_EVENT"
|
2020-12-21 18:46:36 +01:00
|
|
|
env:
|
|
|
|
GITHUB_REF: ${{ github.ref }}
|
|
|
|
GITHUB_EVENT: ${{ github.event_name }}
|
|
|
|
|
|
|
|
- name: Checkout repo
|
2021-05-17 17:18:45 +02:00
|
|
|
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
|
2020-12-21 18:46:36 +01:00
|
|
|
|
2021-09-02 22:05:17 +02:00
|
|
|
- name: NPM install
|
2020-12-21 18:46:36 +01:00
|
|
|
run: npm install
|
|
|
|
|
2021-09-02 22:05:17 +02:00
|
|
|
- name: NPM build
|
2021-08-25 20:15:31 +02:00
|
|
|
run: npm run build:cloud
|