Skip to content
Open
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
27 changes: 19 additions & 8 deletions .github/workflows/sample-apps.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
name: Publish Sample Apps
name: Build and Publish Sample Apps

on:
push:
branches:
- main
pull_request:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's limit this workflow to PRs against the main branch specifically:

Suggested change
pull_request:
pull_request:
branches:
- main


env:
REGISTRY: ghcr.io

jobs:
publish-image:
name: Publish sample app images
build-and-publish:
name: Build and publish sample app images
runs-on: ubuntu-latest
strategy:
matrix:
app: [cpu-load-gen, hello-world, outbound-http, variabletester, redis-sample, salutations]
env:
IMAGE_NAME: ${{ github.repository }}

steps:
- uses: actions/checkout@v5

- name: Set the release version
# This version tag is only needed when publishing the image on a push to main.
- name: Set release version
if: github.ref_name == 'main' && github.event_name == 'push'
shell: bash
run: |
echo "RELEASE_VERSION=$(date +%Y%m%d-%H%M%S)-g$(git rev-parse --short HEAD)" >> $GITHUB_ENV
Expand All @@ -34,11 +35,21 @@ jobs:
with:
tinygo-version: '0.33.0'

- name: Build and push versioned image
# For pull requests, we only build the application to validate it.
- name: Build application on PR
if: github.event_name == 'pull_request'
uses: fermyon/actions/spin/build@v1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alas, there is no fermyon/actions/spin/build action currently offered by https://github.com/fermyon/actions -- or https://github.com/spinframework/actions, the current home for the actions.

For now, we'd have to utilize a run step to invoke the spin binary that was installed by the spin/setup action above:

- name: Run spin build
  if: github.event_name == 'pull_request'
  run: spin build -f apps/${{ matrix.app }}/spin.toml

with:
manifest_file: apps/${{ matrix.app }}/spin.toml

# For pushes to the main branch, we build and push the image to the registry.
# The spin/push action handles the build, login, and push operations.
- name: Build and Push image on main branch push
if: github.ref_name == 'main' && github.event_name == 'push'
uses: fermyon/actions/spin/push@v1
with:
registry: ${{ env.REGISTRY }}
registry_username: ${{ github.actor }}
registry_password: ${{ secrets.GITHUB_TOKEN }}
registry_reference: "ghcr.io/${{ github.repository_owner }}/spin-operator/${{ matrix.app }}:${{ env.RELEASE_VERSION }}"
manifest_file: apps/${{ matrix.app }}/spin.toml
manifest_file: apps/${{ matrix.app }}/spin.toml