diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..53a3c15 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,27 @@ +name: Test + +on: + push: + branches: + - main + pull_request: + +jobs: + test: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest] + arch: [amd64, arm64] + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - 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 whoami diff --git a/README.md b/README.md index ebfb964..23a7ad7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Setup [Coder](https://github.com/coder/coder) -Downloads and Configures Coder. +Downloads and authenticates Coder's CLI with your Coder server. This action can be used to run authenticated Coder commands in GitHub Action workflows. ## Usage @@ -21,13 +21,13 @@ jobs: - name: Setup Coder uses: coder/setup-action@v1 with: - access_url: 'https://dev.coder.com' + access_url: 'https://coder.example.com' coder_session_token: ${{ secrets.CODER_SESSION_TOKEN }} ``` ## Inputs -| Name | Description | Default | -| ------------------------- | ------------------------------------------------------------------------ | ------- | -| **`access_url`** | **Required** The url of coder deployment (e.g. ). | - | -| **`coder_session_token`** | **Required** The session token of coder. | - | +| Name | Description | Default | +| ------------------------- | ----------------------------------------------------------------------------- | ------- | +| **`access_url`** | **Required** The url of coder deployment (e.g. ). | - | +| **`coder_session_token`** | **Required** The session token of coder. | - | diff --git a/action.yaml b/action.yaml index 6a68dfc..7e43e3e 100644 --- a/action.yaml +++ b/action.yaml @@ -17,8 +17,18 @@ 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 + run: | + if [ "${{ runner.arch }}" == "ARM64" ]; then + ARCH="arm64" + else + ARCH="amd64" + fi + mkdir -p "$HOME"/.local/bin + curl -fsSL --compressed "$CODER_URL"/bin/coder-linux-${ARCH} -o "$HOME"/.local/bin/coder + chmod +x "$HOME"/.local/bin/coder + echo "$HOME/.local/bin" >> $GITHUB_PATH + "$HOME"/.local/bin/coder version shell: bash env: CODER_URL: ${{ inputs.access_url }} @@ -28,4 +38,4 @@ runs: 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 }}