diff --git a/.github/workflows/acceptance-test.yml b/.github/workflows/acceptance-test.yml index be8202e1..abc40b8d 100644 --- a/.github/workflows/acceptance-test.yml +++ b/.github/workflows/acceptance-test.yml @@ -20,7 +20,7 @@ jobs: acceptance-test: strategy: matrix: - os: [ubuntu-latest, macos-latest] + os: [ubuntu-latest, macos-latest, windows-latest] auth: [connect, service-account] exclude: - os: macos-latest @@ -60,11 +60,13 @@ jobs: if: ${{ matrix.auth == 'service-account' }} uses: ./configure with: + runner: ${{ runner.os }} service-account-token: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} - name: Configure 1Password Connect if: ${{ matrix.auth == 'connect' }} uses: ./configure # 1password/load-secrets-action/configure@ with: + runner: ${{ runner.os }} connect-host: http://localhost:8080 connect-token: ${{ secrets.OP_CONNECT_TOKEN }} - name: Load secrets diff --git a/.github/workflows/test-fork.yml b/.github/workflows/test-fork.yml index cdfa9067..78bf81b6 100644 --- a/.github/workflows/test-fork.yml +++ b/.github/workflows/test-fork.yml @@ -12,7 +12,7 @@ jobs: github.event.client_payload.pull_request.head.sha, github.event.client_payload.slash_command.args.named.sha ) - uses: 1password/load-secrets-action/.github/workflows/acceptance-test.yml@main + uses: 1password/load-secrets-action/.github/workflows/acceptance-test.yml@vzt/windows-support secrets: inherit with: secret: op://acceptance-tests/test-secret/password @@ -27,7 +27,7 @@ jobs: github.event.client_payload.pull_request.head.sha, github.event.client_payload.slash_command.args.named.sha ) - uses: 1password/load-secrets-action/.github/workflows/acceptance-test.yml@main + uses: 1password/load-secrets-action/.github/workflows/acceptance-test.yml@vzt/windows-support secrets: inherit with: secret: op://acceptance-tests/test-secret/password @@ -42,7 +42,7 @@ jobs: github.event.client_payload.pull_request.head.sha, github.event.client_payload.slash_command.args.named.sha ) - uses: 1password/load-secrets-action/.github/workflows/acceptance-test.yml@main + uses: 1password/load-secrets-action/.github/workflows/acceptance-test.yml@vzt/windows-support secrets: inherit with: secret: op://v5pz6venw4roosmkzdq2nhpv6u/hrgkzhrlvscomepxlgafb2m3ca/password diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3a934723..b1a4b618 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,7 +21,7 @@ jobs: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository ) - uses: 1password/load-secrets-action/.github/workflows/acceptance-test.yml@main + uses: 1password/load-secrets-action/.github/workflows/acceptance-test.yml@vzt/windows-support secrets: inherit with: secret: op://acceptance-tests/test-secret/password @@ -35,7 +35,7 @@ jobs: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository ) - uses: 1password/load-secrets-action/.github/workflows/acceptance-test.yml@main + uses: 1password/load-secrets-action/.github/workflows/acceptance-test.yml@vzt/windows-support secrets: inherit with: secret: op://acceptance-tests/test-secret/password @@ -49,7 +49,7 @@ jobs: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository ) - uses: 1password/load-secrets-action/.github/workflows/acceptance-test.yml@main + uses: 1password/load-secrets-action/.github/workflows/acceptance-test.yml@vzt/windows-support secrets: inherit with: secret: op://v5pz6venw4roosmkzdq2nhpv6u/hrgkzhrlvscomepxlgafb2m3ca/password diff --git a/configure/action.yml b/configure/action.yml index 40ab9ebe..6f207b23 100644 --- a/configure/action.yml +++ b/configure/action.yml @@ -8,10 +8,25 @@ inputs: description: Token to authenticate to your 1Password Connect instance service-account-token: description: Your 1Password service account token + runner: + description: The runner to use for this action. Valid values are `Linux`, `Windows`, and `macOS`. + default: ubuntu + required: false + type: string runs: using: composite steps: - - shell: bash + - if: ${{ inputs.runner == 'Windows' }} + shell: pwsh + env: + INPUT_CONNECT_HOST: ${{ inputs.connect-host }} + INPUT_CONNECT_TOKEN: ${{ inputs.connect-token }} + INPUT_SERVICE_ACCOUNT_TOKEN: ${{ inputs.service-account-token }} + run: | + ${{ github.action_path }}/entrypoint.ps1 + + - if: ${{ inputs.runner != 'Windows' }} + shell: bash env: INPUT_CONNECT_HOST: ${{ inputs.connect-host }} INPUT_CONNECT_TOKEN: ${{ inputs.connect-token }} diff --git a/configure/entrypoint.ps1 b/configure/entrypoint.ps1 new file mode 100644 index 00000000..e7683337 --- /dev/null +++ b/configure/entrypoint.ps1 @@ -0,0 +1,17 @@ +if ($env:INPUT_CONNECT_HOST) { + Add-Content -Path $env:GITHUB_ENV -Value "OP_CONNECT_HOST=$($env:INPUT_CONNECT_HOST)" -Encoding utf8 +} elseif ($env:OP_CONNECT_HOST) { + Add-Content -Path $env:GITHUB_ENV -Value "OP_CONNECT_HOST=$($env:OP_CONNECT_HOST)" -Encoding utf8 +} + +if ($env:INPUT_CONNECT_TOKEN) { + Add-Content -Path $env:GITHUB_ENV -Value "OP_CONNECT_TOKEN=$($env:INPUT_CONNECT_TOKEN)" -Encoding utf8 +} elseif ($env:OP_CONNECT_TOKEN) { + Add-Content -Path $env:GITHUB_ENV -Value "OP_CONNECT_TOKEN=$($env:OP_CONNECT_TOKEN)" -Encoding utf8 +} + +if ($env:INPUT_SERVICE_ACCOUNT_TOKEN) { + Add-Content -Path $env:GITHUB_ENV -Value "OP_SERVICE_ACCOUNT_TOKEN=$($env:INPUT_SERVICE_ACCOUNT_TOKEN)" -Encoding utf8 +} elseif ($env:OP_SERVICE_ACCOUNT_TOKEN) { + Add-Content -Path $env:GITHUB_ENV -Value "OP_SERVICE_ACCOUNT_TOKEN=$($env:OP_SERVICE_ACCOUNT_TOKEN)" -Encoding utf8 +} \ No newline at end of file diff --git a/install_cli.sh b/install_cli.sh index 0d39259b..667856a7 100755 --- a/install_cli.sh +++ b/install_cli.sh @@ -14,7 +14,7 @@ install_op_cli() { # Get the latest stable version of the CLI CLI_VERSION="v$(curl https://app-updates.agilebits.com/check/1/0/CLI2/en/2.0.0/N -s | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')" - if [[ "$OSTYPE" == "linux-gnu"* ]]; then + if [[ "$RUNNER_OS" == "Linux" ]]; then # Get runner's architecture ARCH=$(uname -m) if [[ "$(getconf LONG_BIT)" = 32 ]]; then @@ -32,13 +32,16 @@ install_op_cli() { curl -sSfLo op.zip "https://cache.agilebits.com/dist/1P/op2/pkg/${CLI_VERSION}/op_linux_${ARCH}_${CLI_VERSION}.zip" unzip -od "$OP_INSTALL_DIR" op.zip && rm op.zip - elif [[ "$OSTYPE" == "darwin"* ]]; then + elif [[ "$RUNNER_OS" == "macOS" ]]; then curl -sSfLo op.pkg "https://cache.agilebits.com/dist/1P/op2/pkg/${CLI_VERSION}/op_apple_universal_${CLI_VERSION}.pkg" pkgutil --expand op.pkg temp-pkg tar -xvf temp-pkg/op.pkg/Payload -C "$OP_INSTALL_DIR" rm -rf temp-pkg && rm op.pkg + elif [ "$RUNNER_OS" = "Windows" ]; then + pwsh -Command "Invoke-WebRequest -Uri https://cache.agilebits.com/dist/1P/op2/pkg/${CLI_VERSION}/op_windows_amd64_${CLI_VERSION}.zip -OutFile op.zip" + pwsh -Command "Expand-Archive -Path op.zip -DestinationPath '${OP_INSTALL_DIR}'; Remove-Item op.zip" else - echo "Operating system not supported yet for this GitHub Action: $OSTYPE." + echo "Operating system not supported yet for this GitHub Action: $RUNNER_OS." exit 1 fi }