Skip to content
Latchkey

Deploy to staging or prod and test workflow (polyfillpolyfill/polyfill-service)

The Deploy to staging or prod and test workflow from polyfillpolyfill/polyfill-service, explained and optimized by Latchkey.

C

CI health: C - fair

Point runs-on at Latchkey and get caching, job timeouts, self-healing for flaky steps, and up to 58% lower cost, applied automatically.

Grade your own workflow free or run it on Latchkey →
Source: polyfillpolyfill/polyfill-service.github/workflows/deploy-to-staging-and-test.ymlLicense MITView source

What it does

This is the Deploy to staging or prod and test workflow from the polyfillpolyfill/polyfill-service repository, a real project running GitHub Actions. It is shown here with attribution under its MIT license.

Below, Latchkey shows a faster, safer version produced by its optimization engine.

The workflow

workflow (.yml)
name: Deploy to staging or prod and test
concurrency: staging_environment
on:
  push:
    branches: [ main ]
env:
  fastly_vcl_service_id: 2l7QhcR5rkdg691tcdRTD7
  fastly_compute_service_id: 4cUBTkiSVlJnR8JPnLvt85
  fastly_top_pops_config: 4dfSlimwvlJELO6htcnGsi
  fastly_compute_edge_config: 52hxZN9sNy7jyAdvvGKekc
  domain: qa.polyfill.io
jobs:
  deploy-to-staging:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # pin@v3
      - uses: actions-rust-lang/setup-rust-toolchain@b113a30d27a8e59c969077c0a0168cc13dab5ffc # pin@v1
      - name: Set cache-key
        id: cache-key
        run: echo "CACHE_KEY=compute-package-$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
      - name: Restore compute-package from cache
        uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # pin@v3
        id: compute-package
        with:
          path: pkg/package.tar.gz
          key: ${{ steps.cache-key.outputs.CACHE_KEY }}
      - if: steps.compute-package.outputs.cache-hit != 'true'
        name: Set up Fastly CLI
        uses: fastly/compute-actions/setup@c2f38daa58a1a6562575c9665f13b080803b8989 # pin@v5
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          cli_version: '10.4.0'
      - if: steps.compute-package.outputs.cache-hit != 'true'
        run: fastly compute build --package-name package
      - uses: actions/upload-artifact@1eb3cb2b3e0f29609092a73eb033bb759a334595 # pin@v3
        with:
          name: ${{ steps.cache-key.outputs.CACHE_KEY }}
          path: pkg/package.tar.gz
      - uses: ./.github/actions/terraform
        with:
          cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
          terraform_working_dir: fastly/terraform/staging
          fastly-api-token: ${{ secrets.FASTLY_API_KEY }}
          fastly_vcl_service_id: ${{ env.fastly_vcl_service_id }}
          fastly_compute_service_id: ${{ env.fastly_compute_service_id }}
          fastly_top_pops_config: ${{ env.fastly_top_pops_config }}
          fastly_compute_edge_config: ${{ env.fastly_compute_edge_config }}

  end-to-end-test:
    needs: [ deploy-to-staging ]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # pin@v3
      - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # pin@v4.0.1
        with:
          node-version: 18.x
      - name: 'Install test dependencies'
        run: npm ci
        working-directory: "./test"
      - run: npm run test:integration
        working-directory: "./test"
        env:
          HOST: "https://${{ env.domain }}"

The same workflow, on Latchkey

Estimated ~20% faster on cache hits, plus fewer wasted runs and a safer supply chain. Added and changed lines are highlighted.

name: Deploy to staging or prod and test
concurrency: staging_environment
on:
  push:
    branches: [ main ]
env:
  fastly_vcl_service_id: 2l7QhcR5rkdg691tcdRTD7
  fastly_compute_service_id: 4cUBTkiSVlJnR8JPnLvt85
  fastly_top_pops_config: 4dfSlimwvlJELO6htcnGsi
  fastly_compute_edge_config: 52hxZN9sNy7jyAdvvGKekc
  domain: qa.polyfill.io
jobs:
  deploy-to-staging:
    timeout-minutes: 30
    runs-on: latchkey-small
    steps:
      - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # pin@v3
      - uses: actions-rust-lang/setup-rust-toolchain@b113a30d27a8e59c969077c0a0168cc13dab5ffc # pin@v1
      - name: Set cache-key
        id: cache-key
        run: echo "CACHE_KEY=compute-package-$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
      - name: Restore compute-package from cache
        uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # pin@v3
        id: compute-package
        with:
          path: pkg/package.tar.gz
          key: ${{ steps.cache-key.outputs.CACHE_KEY }}
      - if: steps.compute-package.outputs.cache-hit != 'true'
        name: Set up Fastly CLI
        uses: fastly/compute-actions/setup@c2f38daa58a1a6562575c9665f13b080803b8989 # pin@v5
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          cli_version: '10.4.0'
      - if: steps.compute-package.outputs.cache-hit != 'true'
        run: fastly compute build --package-name package
      - uses: actions/upload-artifact@1eb3cb2b3e0f29609092a73eb033bb759a334595 # pin@v3
        with:
          name: ${{ steps.cache-key.outputs.CACHE_KEY }}
          path: pkg/package.tar.gz
      - uses: ./.github/actions/terraform
        with:
          cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
          terraform_working_dir: fastly/terraform/staging
          fastly-api-token: ${{ secrets.FASTLY_API_KEY }}
          fastly_vcl_service_id: ${{ env.fastly_vcl_service_id }}
          fastly_compute_service_id: ${{ env.fastly_compute_service_id }}
          fastly_top_pops_config: ${{ env.fastly_top_pops_config }}
          fastly_compute_edge_config: ${{ env.fastly_compute_edge_config }}
 
  end-to-end-test:
    timeout-minutes: 30
    needs: [ deploy-to-staging ]
    runs-on: latchkey-small
    steps:
      - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # pin@v3
      - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # pin@v4.0.1
        with:
          cache: 'npm'
          node-version: 18.x
      - name: 'Install test dependencies'
        run: npm ci
        working-directory: "./test"
      - run: npm run test:integration
        working-directory: "./test"
        env:
          HOST: "https://${{ env.domain }}"
 

What changed

What Latchkey heals here

This workflow has steps that commonly fail on transient issues (network, registries, flaky browsers). On Latchkey managed runners they are detected, retried, and self-healed instead of failing your build:

This workflow runs 2 jobs per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow