Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,30 @@ jobs:
| `FASTLY_API_TOKEN` | string | personal [Fastly API token](https://manage.fastly.com/account/personal/tokens) |


## alternative usage

This workflow can also be used to only install the Fastly CLI. If you want to use an API token that has a strictly limited permission grant, you will need to use this option.

To do that pass an environment variable `SKIP_CONFIGURE` with any value. The `FASTLY_API_TOKEN` is not required in this case.

For steps following the installation, you will need to provide the CLI with an API token, by either exporting a `FASTLY_API_TOKEN` environment variable, or by providing it to the CLI explicitly as part of the command line. See the [Fastly CLI documentation](https://developer.fastly.com/reference/cli/#configuring) for details.

### example

```yml
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Fastly CLI
uses: softprops/setup-fastly-cli@v1
env:
SKIP_CONFIGURE: yes
- name: Purge Fastly
FASTLY_API_TOKEN: ${{ secrets.FASTLY_API_TOKEN }}
run: fastly purge --key "*/beepboop"
```

Doug Tangren (softprops) 2020
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

17 changes: 11 additions & 6 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,20 @@ async function run() {
if (!version) {
throw new Error("Failed to resolve latest version");
}
const fastlyToken = process.env.FASTLY_API_TOKEN;
if (!fastlyToken) {
throw new Error("Please provide an FASTLY_API_TOKEN env variable");
}

await install(version, os.platform());
await exec.exec("fastly", ["configure", "--token", fastlyToken]);

const doConfigure = process.env.SKIP_CONFIGURE == undefined;
if (doConfigure) {
const fastlyToken = `${process.env.FASTLY_API_TOKEN}`;
if (fastlyToken == "") {
throw new Error("Expected FASTLY_API_TOKEN to not be empty");
}

await exec.exec("fastly", ["configure", "--token", fastlyToken]);
}
} catch (error) {
setFailed(error.message);
setFailed((error as Error).message);
}
}

Expand Down