|
| 1 | +# Shipyard Github Action |
| 2 | + |
| 3 | +[](https://raw.githubusercontent.com/shipyard/github-action/master/LICENSE) [](https://github.community/c/github-ecosystem/github-apps/64) |
| 4 | + |
| 5 | +Use Github Action to run jobs on ephemeral environments automatically deployed by Shipyard, authenticating into them via a bypass token. |
| 6 | +This job connects with Shipyard during a Github Action job, fetching necessary environment variables in order to run e2e tests where authentication via OAuth is normally required. |
| 7 | + |
| 8 | +## How to use |
| 9 | + |
| 10 | +In your Github Workflow file located in `.github/workflows/`, you can use the Shipyard's Github Action as per the following example: |
| 11 | + |
| 12 | +``` |
| 13 | +on: [pull_request] |
| 14 | +
|
| 15 | +jobs: |
| 16 | + cypress-e2e-tests: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + name: Collect the bypass token and URL for an authenticated ephemeral environment attached to this PR in order to run e2e tests on it. |
| 19 | + steps: |
| 20 | + - name: Checkout |
| 21 | + uses: actions/checkout@v2 |
| 22 | + - name: Fetch Shipyard Tokens |
| 23 | + uses: shipyard/github-action/fetch-shipyard-env@1.0.0 |
| 24 | + env: |
| 25 | + SHIPYARD_API_TOKEN: ${{ secrets.SHIPYARD_API_TOKEN }} |
| 26 | + - name: Run the e2e tests on the ephemeral environment |
| 27 | + run: npm run test |
| 28 | + shell: bash |
| 29 | + env: |
| 30 | + CYPRESS_BASE_URL: $SHIPYARD_ENVIRONMENT_URL |
| 31 | + CYPRESS_BYPASS_TOKEN: $SHIPYARD_BYPASS_TOKEN |
| 32 | + |
| 33 | +``` |
| 34 | + |
| 35 | +The Github Action can be configured by passing inputs or environment variables: |
| 36 | + |
| 37 | +**Inputs** |
| 38 | +``` |
| 39 | + - name: Fetch Shipyard Tokens |
| 40 | + uses: shipyard/github-action/fetch-shipyard-env@1.0.0 |
| 41 | + with: |
| 42 | + api-token: ${{ secrets.SHIPYARD_API_TOKEN }} |
| 43 | + timeout-minutes: 30 |
| 44 | +``` |
| 45 | + |
| 46 | +| Input name | Description | Default Value | |
| 47 | +| --------------- | --------------- |--------------- | |
| 48 | +| `api-token` | Token required to connect to Shipyard's APIs. Can be obtained from your Organization's setting page | -| |
| 49 | +| `timeout-minutes` | Number of minutes to wait for Shipyard environment before timing out. | 60| |
| 50 | + |
| 51 | + |
| 52 | +**Environment Variables** |
| 53 | +``` |
| 54 | + - name: Fetch Shipyard Tokens |
| 55 | + uses: shipyard/github-action/fetch-shipyard-env@1.0.0 |
| 56 | + env: |
| 57 | + SHIPYARD_API_TOKEN: ${{ secrets.SHIPYARD_API_TOKEN }} |
| 58 | + SHIPYARD_TIMEOUT: 30 |
| 59 | +``` |
| 60 | + |
| 61 | +| Environment Variable | Description | Default Value | |
| 62 | +| --------------- | --------------- |--------------- | |
| 63 | +| `SHIPYARD_API_TOKEN` | Token required to connect to Shipyard's APIs. Can be obtained from your Organization's setting page |-| |
| 64 | +| `SHIPYARD_TIMEOUT` | Number of minutes to wait for Shipyard environment before timing out. |60| |
| 65 | + |
| 66 | +**NOTE**: Inputs are given precedence over environment variables. |
| 67 | + |
| 68 | +If input `api-token` or environment variable `SHIPYARD_API_TOKEN` is not provided, error is raised. |
| 69 | + |
| 70 | +On successful run, the following environment variables are set, which can then be passed on to other actions in the same workflow. |
| 71 | + |
| 72 | +| Parameter Name | Description | |
| 73 | +| --------------- | --------------- | |
| 74 | +|`SHIPYARD_ENVIRONMENT_URL` | URL of the ephemeral environment | |
| 75 | +|`SHIPYARD_BYPASS_TOKEN` | Token to bypass authentication | |
| 76 | + |
| 77 | + |
| 78 | +## Resources |
| 79 | + |
| 80 | +[Shipyard Documentation](https://docs.shipyard.build/docs/) |
0 commit comments