diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..7b4ed84 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,32 @@ +name: Test + +on: + push: + branches: + - main + pull_request: + +jobs: + test: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + arch: [amd64, arm64] + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: List directory contents + run: ls -R + + - name: Run Setup Coder Action + uses: ./ + with: + access_url: ${{ secrets.CODER_URL }} + coder_session_token: ${{ secrets.CODER_SESSION_TOKEN }} + + - name: Run Coder CLI + run: | + coder version + coder whoami diff --git a/action.yaml b/action.yaml index 6a68dfc..5069e07 100644 --- a/action.yaml +++ b/action.yaml @@ -17,15 +17,48 @@ inputs: runs: using: "composite" steps: - - name: Download Coder binary from access URL - run: curl -fsSL $CODER_URL/bin/coder-linux-amd64 -o /usr/local/bin/coder && chmod +x /usr/local/bin/coder + - name: Download and install Coder binary (Windows) + if: runner.os == 'Windows' + run: | + if (${{ runner.arch }} -eq "ARM64") { + $ARCH = "arm64" + } else { + $ARCH = "amd64" + } + curl -fsSL ${{ inputs.access_url }}/bin/coder-windows-$ARCH.exe -o $env:USERPROFILE\AppData\Local\bin\coder.exe + echo "$env:USERPROFILE\AppData\Local\bin" >> $GITHUB_PATH + shell: pwsh + + - name: Download and install Coder binary (Linux/macOS) + if: runner.os != 'Windows' + run: | + if [ "${{ runner.arch }}" == "ARM64" ]; then + ARCH="arm64" + else + ARCH="amd64" + fi + if [ "${{ runner.os }}" == "macOS" ]; then + OS="darwin" + else + OS="linux" + fi + curl -fsSL ${{ inputs.access_url }}/bin/coder-${OS}-${ARCH} -o $HOME/.local/bin/coder + chmod +x $HOME/.local/bin/coder + echo "$HOME/.local/bin" >> $GITHUB_PATH shell: bash + + - name: Login to Coder (Windows) + if: runner.os == 'Windows' + run: coder login --token $CODER_SESSION_TOKEN $CODER_URL + shell: pwsh env: CODER_URL: ${{ inputs.access_url }} + CODER_SESSION_TOKEN: ${{ inputs.coder_session_token }} - - name: Login to Coder + - name: Login to Coder (Linux/macOS) + if: runner.os != 'Windows' run: coder login --token $CODER_SESSION_TOKEN $CODER_URL shell: bash env: CODER_URL: ${{ inputs.access_url }} - CODER_SESSION_TOKEN: ${{ inputs.coder_session_token }} \ No newline at end of file + CODER_SESSION_TOKEN: ${{ inputs.coder_session_token }}