Skip to content
Latchkey

Update Latest Version workflow (run-x/opta)

The Update Latest Version workflow from run-x/opta, explained and optimized by Latchkey.

B

CI health: B - good

Run this on Latchkey for self-healing, caching, and up to 58% lower cost.

Grade your own workflow free or run it on Latchkey →
Source: run-x/opta.github/workflows/update-latest.ymlLicense Apache-2.0View source

What it does

This is the Update Latest Version workflow from the run-x/opta 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

workflow (.yml)
name: Update Latest Version
on: 
  workflow_dispatch:
    inputs:
      version:
        description: Opta version to mark as latest
        required: true
jobs:
  update_s3_file:
    runs-on: ubuntu-18.04
    env:
      VERSION: ${{ github.event.inputs.version }}
    steps:
      - name: validate version
        run: |
          /bin/bash -c "$(curl -fsSL https://docs.opta.dev/install.sh)"
          export VERSION_FOUND=$(/home/runner/.opta/opta version | head -n 1)
          if [ "$VERSION" = "$VERSION_FOUND" ]; then
              echo "Valid version"
          else
              echo "Invalid version"
              exit 1
          fi
      - name: Configure AWS credentials
        uses: aws-actions/configure-aws-credentials@v1
        with:
          aws-access-key-id: ${{ secrets.AWS_S3_ACCESS_KEY_ID }}
          aws-secret-access-key: ${{ secrets.AWS_S3_SECRET_ACCESS_KEY }}
          aws-region: us-east-1
      - name: Upload to S3
        run: |
          echo $VERSION > latest
          aws s3 cp latest s3://dev-runx-opta-binaries/latest --acl public-read

The same workflow, on Latchkey

Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.

name: Update Latest Version
on: 
  workflow_dispatch:
    inputs:
      version:
        description: Opta version to mark as latest
        required: true
jobs:
  update_s3_file:
    timeout-minutes: 30
    runs-on: ubuntu-18.04
    env:
      VERSION: ${{ github.event.inputs.version }}
    steps:
      - name: validate version
        run: |
          /bin/bash -c "$(curl -fsSL https://docs.opta.dev/install.sh)"
          export VERSION_FOUND=$(/home/runner/.opta/opta version | head -n 1)
          if [ "$VERSION" = "$VERSION_FOUND" ]; then
              echo "Valid version"
          else
              echo "Invalid version"
              exit 1
          fi
      - name: Configure AWS credentials
        uses: aws-actions/configure-aws-credentials@v1
        with:
          aws-access-key-id: ${{ secrets.AWS_S3_ACCESS_KEY_ID }}
          aws-secret-access-key: ${{ secrets.AWS_S3_SECRET_ACCESS_KEY }}
          aws-region: us-east-1
      - name: Upload to S3
        run: |
          echo $VERSION > latest
          aws s3 cp latest s3://dev-runx-opta-binaries/latest --acl public-read
 

What changed

1 third-party action is referenced by a movable tag. Pin it 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.

Actions used in this workflow