-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from digitalocean/v2-experiment
digitalocean/action-doctl v2 rewrite
- Loading branch information
Showing
11 changed files
with
14,378 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"env": { | ||
"browser": true, | ||
"commonjs": true, | ||
"es6": true, | ||
"node": true | ||
}, | ||
"extends": "eslint:recommended", | ||
"globals": { | ||
"Atomics": "readonly", | ||
"SharedArrayBuffer": "readonly" | ||
}, | ||
"parserOptions": { | ||
"ecmaVersion": 2018 | ||
}, | ||
"rules": { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,81 @@ | ||
on: [push, pull_request] | ||
name: Test and lint | ||
|
||
jobs: | ||
|
||
build: | ||
name: Lint and test build | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@master | ||
- run: npm test | ||
|
||
- name: Checkout master | ||
uses: actions/checkout@master | ||
package_check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@master | ||
- name: "Ensure that code has been packaged and commited" | ||
run: |- | ||
npm install | ||
npm run package | ||
git diff --exit-code dist/index.js || \ | ||
(echo -e "\nPlease run 'npm run package' and commit the results" && exit 1) | ||
test: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, macos-latest, windows-latest] | ||
steps: | ||
- uses: actions/checkout@master | ||
|
||
- name: Install doctl | ||
uses: ./ | ||
with: | ||
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} | ||
|
||
- name: Verify installation | ||
run: doctl version | ||
|
||
- name: Verify log-in | ||
run: doctl compute region list | ||
|
||
test_custom_version_linux_and_mac: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, macos-latest] | ||
steps: | ||
- uses: actions/checkout@master | ||
|
||
- name: Install doctl | ||
uses: ./ | ||
with: | ||
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} | ||
version: 1.38.0 | ||
|
||
- name: Verify installation of correct version | ||
run: | | ||
VERSION=$(doctl version | head -1 | cut -f3 -d' ' | cut -f1 -d'-') | ||
if [ "$VERSION" != "1.38.0" ]; then exit 1; fi | ||
- name: Verify log-in | ||
run: doctl compute region list | ||
|
||
test_custom_version_windows: | ||
runs-on: windows-latest | ||
steps: | ||
- uses: actions/checkout@master | ||
|
||
- name: Install doctl | ||
uses: ./ | ||
with: | ||
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} | ||
version: 1.38.0 | ||
|
||
- name: Lint shell scripts | ||
run: shellcheck *.sh | ||
- name: Verify installation of correct version | ||
run: | | ||
$VERSION = (doctl version | head -1 | cut -f3 -d' ' | cut -f1 -d'-') | ||
If (-NOT ($VERSION -eq "1.38.0")) { exit 1 } | ||
- name: Test build doctl container | ||
run: docker build $GITHUB_WORKSPACE | ||
- name: Verify log-in | ||
run: doctl compute region list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules/ | ||
.npm | ||
.eslintcache |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,40 @@ | ||
# GitHub Actions for DigitalOcean | ||
|
||
This action enables you to interact with [DigitalOcean](https://www.digitalocean.com/) services via [the `doctl` command-line client](https://github.com/digitalocean/doctl). | ||
This action enables you to interact with [DigitalOcean](https://www.digitalocean.com/) services by installing [the `doctl` command-line client](https://github.com/digitalocean/doctl). | ||
|
||
## Usage | ||
|
||
As an example, one common use case is retrieving the credentials for a Kubernetes cluster hosted on DigitalOcean for use in a deployment workflow: | ||
To install the latest version of `doctl` and use it in GitHub Actions workflows, add the following step: | ||
|
||
```yaml | ||
- name: Install doctl | ||
uses: digitalocean/action-doctl@v2 | ||
with: | ||
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} | ||
``` | ||
`doctl` will now be available in the virtual environment and can be used directly in following steps. As an example, one common use case is retrieving the credentials for a Kubernetes cluster hosted on DigitalOcean for use in a deployment workflow: | ||
|
||
```yaml | ||
- name: Save DigitalOcean kubeconfig | ||
uses: digitalocean/action-doctl@master | ||
env: | ||
DIGITALOCEAN_ACCESS_TOKEN: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} | ||
with: | ||
args: kubernetes cluster kubeconfig show k8s-cluster-name > $GITHUB_WORKSPACE/.kubeconfig | ||
run: doctl kubernetes cluster kubeconfig save testing-cluster | ||
``` | ||
|
||
See [this repository](https://github.com/andrewsomething/example-doctl-action) for a full end-to-end example that also demonstrates building the Docker image, pushing it to Docker Hub, and using `kubectl` to deploy to the Kubernetes cluster on DigitalOcean. | ||
See [this repository](https://github.com/do-community/example-doctl-action) for a full end-to-end example that also demonstrates building a Docker image, pushing it to Docker Hub, and using `kubectl` to deploy it to the Kubernetes cluster on DigitalOcean. | ||
|
||
### Secrets | ||
### Arguments | ||
|
||
- `DIGITALOCEAN_ACCESS_TOKEN` – **Required** A DigitalOcean personal access token ([more info](https://www.digitalocean.com/docs/api/create-personal-access-token/)). | ||
- `token` – (**Required**) A DigitalOcean personal access token ([more info](https://www.digitalocean.com/docs/api/create-personal-access-token/)). | ||
- `version` – (Optional) The version of `doctl` to install. If excluded, the latest release will be used. | ||
|
||
### Environment variables | ||
## Contributing | ||
|
||
We provide defaults for the following, these may also be overridden: | ||
To install the needed dependencies, run `npm install`. The resulting `node_modules/` directory _is not_ checked in to Git. | ||
|
||
- `DIGITALOCEAN_OUTPUT_FORMAT`- **Optional** doctl's output output format, defaults to `json` | ||
Before submitting a pull request, run `npm run package` to package the code [using `ncc`](https://github.com/zeit/ncc#ncc). Packaging assembles the code including dependencies into one file in the `dist/` directory that is checked in to Git. | ||
|
||
By default, this action is configured to save output in JSON format to `${HOME}/${GITHUB_ACTION}.${DIGITALOCEAN_OUTPUT_FORMAT}`for consumption by downstream actions. | ||
Pull requests should be made against the `v2` branch. | ||
|
||
## License | ||
|
||
The Dockerfile and associated scripts and documentation in this project are released under the [MIT License](LICENSE). | ||
This GitHub Action and associated scripts and documentation in this project are released under the [MIT License](LICENSE). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.