Skip to content

Commit

Permalink
Merge pull request #46 from fastly/integralist/fix-bugs
Browse files Browse the repository at this point in the history
fix: bugs
  • Loading branch information
Integralist authored Mar 8, 2024
2 parents 6cad1de + a4ed36a commit 0364c1d
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 62 deletions.
27 changes: 13 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.54.0 # current Rust toolchain for Compute
target: wasm32-wasi # WebAssembly target
targets: wasm32-wasi # WebAssembly target

- name: Deploy to Compute
uses: fastly/compute-actions@v5
Expand All @@ -48,7 +47,7 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install project dependencies
run: npm install
Expand Down Expand Up @@ -85,7 +84,7 @@ jobs:
- name: Set up Fastly CLI
uses: fastly/compute-actions/setup@v5
with:
cli_version: '0.36.0' # optional, defaults to 'latest'
cli_version: '1.0.0' # optional, defaults to 'latest'
token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Dependencies
Expand Down Expand Up @@ -121,7 +120,7 @@ jobs:
run:
shell: bash
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: fastly/compute-actions/preview@v5
with:
fastly-api-token: ${{ secrets.FASTLY_API_KEY }}
Expand All @@ -132,13 +131,13 @@ jobs:

The following inputs can be used as `with` keys for the actions in this repository; none of them are required:

* `project_directory` - Directory of the project to deploy, relative to the repository root.
* `cli_version` - The version of the Fastly CLI to install, e.g. v0.20.0
* `service_id` - The Fastly service ID to deploy to. Defaults to the value in `fastly.toml`. (deploy only)
* `comment` - An optional comment to be included with the deployed service version. (deploy only)
* `version` - Version to clone from when deploying. Can be "latest", "active", or the number of a specific version. (deploy only)
* `verbose` - Set to true to enable verbose logging.
* `token` - The GitHub token to use when interacting with the GitHub API.
- `project_directory` - Directory of the project to deploy, relative to the repository root.
- `cli_version` - The version of the Fastly CLI to install, e.g. v0.20.0
- `service_id` - The Fastly service ID to deploy to. Defaults to the value in `fastly.toml`. (deploy only)
- `comment` - An optional comment to be included with the deployed service version. (deploy only)
- `version` - Version to clone from when deploying. Can be "latest", "active", or the number of a specific version. (deploy only)
- `verbose` - Set to true to enable verbose logging.
- `token` - The GitHub token to use when interacting with the GitHub API.

## Security issues

Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ inputs:
required: false

runs:
using: node16
using: node20
pre: setup/index.js
main: build/index.js
post: deploy/index.js
4 changes: 2 additions & 2 deletions build/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const core = require('@actions/core');
const exec = require('@actions/exec');

const checkCLI = require('../util/bin');
const checkBin = require('../util/bin');

const verbose = core.getBooleanInput('verbose');

checkCLI('fastly', 'version').then(() => {
checkBin('fastly', 'version').then(() => {
let params = ['compute', 'build', '--non-interactive'];
if (verbose) params.push('--verbose');

Expand Down
4 changes: 2 additions & 2 deletions deploy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ const artifact = require('@actions/artifact');
const glob = require('@actions/glob');
const path = require('path');

const checkCLI = require('../util/cli');
const checkBin = require('../util/bin');

const projectDirectory = core.getInput('project_directory');
const serviceId = core.getInput('service_id');
const comment = core.getInput('comment');
const verbose = core.getBooleanInput('verbose');
const version = core.getInput('version');

checkCLI().then(async () => {
checkBin('fastly', 'version').then(async () => {
let params = ['compute', 'deploy', '--non-interactive'];
if (serviceId !== 'default') params.push('--service-id=' + serviceId);
if (verbose) params.push('--verbose');
Expand Down
88 changes: 45 additions & 43 deletions preview/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,46 +18,48 @@ outputs:
value: ${{ steps.service-name.outputs.SERVICE_NAME }}

runs:
using: "composite"
steps:
- uses: actions/checkout@v3
# Download Fastly CLI
- name: Set up Fastly CLI
uses: fastly/compute-actions/setup@v4
with:
token: ${{ inputs.github-token }}
cli_version: '10.2.4'
- run: yarn
shell: bash

# Create a new Fastly Service name with the PR number appended
- name: Set service-name
id: service-name
run: echo "SERVICE_NAME=$(yq '.name' fastly.toml)-${{ github.event.number }}" >> "$GITHUB_OUTPUT"
shell: bash

# Delete the Fastly Service
- if: github.event.action == 'closed'
run: fastly service delete --quiet --service-name ${{ steps.service-name.outputs.SERVICE_NAME }} --force --token ${{ inputs.fastly-api-token }} || true
shell: bash

# Deploy to Fastly and let Fastly choose a subdomain of edgecompute.app to attach to the service
- if: github.event.action != 'closed'
run: |
fastly compute publish --verbose -i --token ${{ inputs.fastly-api-token }} --service-name ${{ steps.service-name.outputs.SERVICE_NAME }}
shell: bash
# Retrieve the newly created domain for the service and add it to the pull-request summary
- if: github.event.action != 'closed'
run: fastly domain list --quiet --version latest --json --service-name="${{ steps.service-name.outputs.SERVICE_NAME }}" --token ${{ inputs.fastly-api-token }} | jq -r '.[0].Name'
shell: bash

- if: github.event.action != 'closed'
name: Set domain
shell: bash
id: domain
run: echo "DOMAIN=$(fastly domain list --quiet --version latest --json --service-name="${{ steps.service-name.outputs.SERVICE_NAME }}" --token ${{ inputs.fastly-api-token }} | jq -r '.[0].Name')" >> "$GITHUB_OUTPUT"

- if: github.event.action != 'closed'
shell: bash
name: Add domain to summary
run: echo 'This pull-request has been deployed to Fastly and is available at <https://${{ steps.domain.outputs.DOMAIN }}> 🚀' >> $GITHUB_STEP_SUMMARY
using: "composite"
steps:
- uses: actions/checkout@v4

# Download Fastly CLI
- name: Set up Fastly CLI
uses: fastly/compute-actions/setup@v5
with:
token: ${{ inputs.github-token }}
cli_version: '10.8.4'
- run: yarn
shell: bash

# Create a new Fastly Service name with the PR number appended
- name: Set service-name
id: service-name
run: echo "SERVICE_NAME=$(yq '.name' fastly.toml)-${{ github.event.number }}" >> "$GITHUB_OUTPUT"
shell: bash

# Delete the Fastly Service
- if: github.event.action == 'closed'
run: fastly service delete --quiet --service-name ${{ steps.service-name.outputs.SERVICE_NAME }} --force --token ${{ inputs.fastly-api-token }} || true
shell: bash

# Deploy to Fastly and let Fastly choose a subdomain of edgecompute.app to attach to the service
- if: github.event.action != 'closed'
run: |
fastly compute publish --verbose -i --token ${{ inputs.fastly-api-token }} --service-name ${{ steps.service-name.outputs.SERVICE_NAME }}
shell: bash

# Retrieve the newly created domain for the service and add it to the pull-request summary
- if: github.event.action != 'closed'
run: fastly domain list --quiet --version latest --json --service-name="${{ steps.service-name.outputs.SERVICE_NAME }}" --token ${{ inputs.fastly-api-token }} | jq -r '.[0].Name'
shell: bash

- if: github.event.action != 'closed'
name: Set domain
shell: bash
id: domain
run: echo "DOMAIN=$(fastly domain list --quiet --version latest --json --service-name="${{ steps.service-name.outputs.SERVICE_NAME }}" --token ${{ inputs.fastly-api-token }} | jq -r '.[0].Name')" >> "$GITHUB_OUTPUT"

- if: github.event.action != 'closed'
shell: bash
name: Add domain to summary
run: echo 'This pull-request has been deployed to Fastly and is available at <https://${{ steps.domain.outputs.DOMAIN }}> 🚀' >> $GITHUB_STEP_SUMMARY

0 comments on commit 0364c1d

Please sign in to comment.