snapcraft-candidate workflow (digitalocean/doctl)
The snapcraft-candidate workflow from digitalocean/doctl, explained and optimized by Latchkey.
CI health: C - fair
Run this on Latchkey for self-healing, caching, and up to 58% lower cost.
Grade your own workflow free or run it on Latchkey →What it does
This is the snapcraft-candidate workflow from the digitalocean/doctl repository, a real project running GitHub Actions. It is shown here with attribution under its Apache-2.0 license.
Below, Latchkey shows a faster, safer version produced by its optimization engine.
The workflow
name: snapcraft-candidate
# Builds and publishes the package to the candidate channel on merge to main.
on:
push:
branches: [main]
jobs:
build-and-publish:
name: 'Snapcraft: Candidate Release'
runs-on: 'ubuntu-latest'
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
# fetch-depth: 0 fetches all history for all branches and tags
fetch-depth: 0
- name: Build snap
uses: snapcore/action-build@v1
id: build
- uses: snapcore/action-publish@master
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAP_TOKEN }}
with:
snap: ${{ steps.build.outputs.snap }}
release: candidate
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: snapcraft-candidate # Builds and publishes the package to the candidate channel on merge to main. on: push: branches: [main] concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: build-and-publish: timeout-minutes: 30 name: 'Snapcraft: Candidate Release' runs-on: 'ubuntu-latest' steps: - name: Checkout code uses: actions/checkout@v2 with: # fetch-depth: 0 fetches all history for all branches and tags fetch-depth: 0 - name: Build snap uses: snapcore/action-build@v1 id: build - uses: snapcore/action-publish@master env: SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAP_TOKEN }} with: snap: ${{ steps.build.outputs.snap }} release: candidate
What changed
- Cancel superseded runs when a branch or PR gets a newer push.
- Add a job timeout so a hung step cannot burn hours of runner time.
2 third-party actions are referenced by a movable tag. Pin them to the commit SHA (Latchkey resolves and applies this automatically) so a repointed tag cannot change what runs.
This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.