-
Notifications
You must be signed in to change notification settings - Fork 30
fix: CI: Build apps on PRs #440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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: | ||
|
|
||
| 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 | ||
|
|
@@ -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 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alas, there is no For now, we'd have to utilize a |
||
| 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 | ||
There was a problem hiding this comment.
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
mainbranch specifically: