From 58b7ff7274c91fe312bb04d7bc7e7d2416b16bba Mon Sep 17 00:00:00 2001 From: Vince Grassia <593223+vgrassia@users.noreply.github.com> Date: Tue, 11 Jan 2022 10:09:11 -0500 Subject: [PATCH] Update Scripts and Add Update Links workflow (#5) --- .github/workflows/update-links.yml | 55 ++++++++++++++++++++++++++++++ bitwarden.ps1 | 11 +++--- bitwarden.sh | 7 ++-- 3 files changed, 65 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/update-links.yml diff --git a/.github/workflows/update-links.yml b/.github/workflows/update-links.yml new file mode 100644 index 0000000..6cdc7c1 --- /dev/null +++ b/.github/workflows/update-links.yml @@ -0,0 +1,55 @@ +--- +name: Update Links + +on: + release: + types: [published] + +jobs: + update-links: + name: Update Links + runs-on: ubuntu-20.04 + steps: + - name: Login to Azure - Prod Subscription + uses: Azure/login@77f1b2e3fb80c0e8645114159d17008b8a2e475a + with: + creds: ${{ secrets.AZURE_PROD_KV_CREDENTIALS }} + + - name: Retrieve secrets + id: retrieve-secrets + uses: Azure/get-keyvault-secrets@80ccd3fafe5662407cc2e55f202ee34bfff8c403 + with: + keyvault: "bitwarden-prod-kv" + secrets: "rebrandly-apikey" + + - name: Update Bitwarden Script PowerShell Link + uses: bitwarden/gh-actions/update-rebrandly-link@9bc2bb10c26cb4d5a7c1d7c0d0285ae37588c847 + with: + apikey: ${{ steps.retrieve-secrets.outputs.rebrandly-apikey }} + domain: "go.btwrdn.co" + slashtag: "bw-ps" + destination: "https://github.org/bitwarden/self-host/releases/download/${{ env.GITHUB_REF }}/bitwarden.ps1" + + - name: Update Run Script PowerShell Link + uses: bitwarden/gh-actions/update-rebrandly-link@9bc2bb10c26cb4d5a7c1d7c0d0285ae37588c847 + with: + apikey: ${{ steps.retrieve-secrets.outputs.rebrandly-apikey }} + domain: "go.btwrdn.co" + slashtag: "bw-ps-run" + destination: "https://github.org/bitwarden/self-host/releases/download/${{ env.GITHUB_REF }}/run.ps1" + + - name: Update Bitwarden Script Shell Link + uses: bitwarden/gh-actions/update-rebrandly-link@9bc2bb10c26cb4d5a7c1d7c0d0285ae37588c847 + with: + apikey: ${{ steps.retrieve-secrets.outputs.rebrandly-apikey }} + domain: "go.btwrdn.co" + slashtag: "bw-sh" + destination: "https://github.org/bitwarden/self-host/releases/download/${{ env.GITHUB_REF }}/bitwarden.sh" + + - name: Update Run Script Shell Link + uses: bitwarden/gh-actions/update-rebrandly-link@9bc2bb10c26cb4d5a7c1d7c0d0285ae37588c847 + with: + apikey: ${{ steps.retrieve-secrets.outputs.rebrandly-apikey }} + domain: "go.btwrdn.co" + slashtag: "bw-sh-run" + destination: "https://github.org/bitwarden/self-host/releases/download/${{ env.GITHUB_REF }}/run.sh" diff --git a/bitwarden.ps1 b/bitwarden.ps1 index 1e6dc22..99d0eed 100644 --- a/bitwarden.ps1 +++ b/bitwarden.ps1 @@ -23,7 +23,8 @@ if ($output -eq "") { } $scriptsDir = "${output}\scripts" -$githubBaseUrl = "https://raw.githubusercontent.com/bitwarden/server/master" +$bitwardenScriptUrl = "https://go.btwrdn.co/bw-ps" +$runScriptUrl = "https://go.btwrdn.co/bw-ps-run" # Please do not create pull requests modifying the version numbers. $coreVersion = "1.45.2" @@ -33,14 +34,14 @@ $keyConnectorVersion = "1.0.0" # Functions function Get-Self { - Invoke-RestMethod -OutFile $scriptPath -Uri "${githubBaseUrl}/scripts/bitwarden.ps1" + Invoke-RestMethod -OutFile $scriptPath -Uri $bitwardenScriptUrl } function Get-Run-File { if (!(Test-Path -Path $scriptsDir)) { New-Item -ItemType directory -Path $scriptsDir | Out-Null } - Invoke-RestMethod -OutFile $scriptsDir\run.ps1 -Uri "${githubBaseUrl}/scripts/run.ps1" + Invoke-RestMethod -OutFile $scriptsDir\run.ps1 -Uri $runScriptUrl } function Test-Output-Dir-Exists { @@ -77,7 +78,7 @@ See more at https://bitwarden.com/help/article/install-on-premise/#script-comman } function Write-Line($str) { - if($env:BITWARDEN_QUIET -ne "true") { + if ($env:BITWARDEN_QUIET -ne "true") { Write-Host $str } } @@ -102,7 +103,7 @@ https://bitwarden.com, https://github.com/bitwarden =================================================== " -if($env:BITWARDEN_QUIET -ne "true") { +if ($env:BITWARDEN_QUIET -ne "true") { Write-Line "bitwarden.ps1 version ${coreVersion}" docker --version docker-compose --version diff --git a/bitwarden.sh b/bitwarden.sh index 9982643..991e38d 100755 --- a/bitwarden.sh +++ b/bitwarden.sh @@ -31,7 +31,8 @@ then fi SCRIPTS_DIR="$OUTPUT/scripts" -GITHUB_BASE_URL="https://raw.githubusercontent.com/bitwarden/server/master" +BITWARDEN_SCRIPT_URL="https://go.btwrdn.co/bw-sh" +RUN_SCRIPT_URL="https://go.btwrdn.co/bw-sh-run" # Please do not create pull requests modifying the version numbers. COREVERSION="1.45.2" @@ -47,7 +48,7 @@ echo "" # Functions function downloadSelf() { - if curl -s -w "http_code %{http_code}" -o $SCRIPT_PATH.1 $GITHUB_BASE_URL/scripts/bitwarden.sh | grep -q "^http_code 20[0-9]" + if curl -L -s -w "http_code %{http_code}" -o $SCRIPT_PATH.1 $BITWARDEN_SCRIPT_URL | grep -q "^http_code 20[0-9]" then mv $SCRIPT_PATH.1 $SCRIPT_PATH chmod u+x $SCRIPT_PATH @@ -61,7 +62,7 @@ function downloadRunFile() { then mkdir $SCRIPTS_DIR fi - curl -s -o $SCRIPTS_DIR/run.sh $GITHUB_BASE_URL/scripts/run.sh + curl -L -s -o $SCRIPTS_DIR/run.sh $RUN_SCRIPT_URL chmod u+x $SCRIPTS_DIR/run.sh rm -f $SCRIPTS_DIR/install.sh }