chore(cloud-hello): Handle UI build in CI #88
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: cloud-hello | |
on: | |
pull_request: | |
paths: | |
- 'cloud-hello/**' | |
merge_group: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
tags: | |
- cloud-hello-v* | |
env: | |
REGISTRY: ghcr.io | |
REPOSITORY: ${{ github.repository }} | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- run: cargo clippy --no-deps | |
working-directory: cloud-hello | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- run: | | |
rustup target add wasm32-wasi | |
cargo build --target wasm32-wasi | |
working-directory: cloud-hello | |
build-ui: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- run: | | |
npm install | |
npm run build | |
working-directory: cloud-hello/ui | |
- uses: actions/upload-artifact@v4 | |
id: upload-cloud-hello-ui | |
with: | |
if-no-files-found: error | |
name: cloud-hello-ui | |
path: cloud-hello/ui/dist/ | |
view-ui: | |
runs-on: ubuntu-latest | |
needs: | |
- build-ui | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: cloud-hello-ui | |
path: cloud-hello/ui/dist | |
- run: | | |
ls -lahR cloud-hello/ui | |
release: | |
runs-on: ubuntu-latest | |
needs: | |
- build | |
- build-ui | |
if: startsWith(github.ref, 'refs/tags/cloud-hello-v') | |
permissions: | |
contents: read | |
packages: write | |
attestations: write | |
id-token: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Extract tag context | |
id: ctx | |
run: | | |
sha_short=$(git rev-parse --short HEAD) | |
echo "owner=${GITHUB_REPOSITORY_OWNER,,}" >> "$GITHUB_OUTPUT" | |
echo "sha_short=${sha_short}" >> "$GITHUB_OUTPUT" | |
echo "version=${GITHUB_REF#refs/tags/cloud-hello-v}" >> "$GITHUB_OUTPUT" | |
- run: rustup target add wasm32-wasi | |
- uses: taiki-e/install-action@v2 | |
with: | |
tool: wash-cli@0.29.2 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: cloud-hello-ui | |
path: cloud-hello/ui/dist | |
- name: Build and push | |
run: | | |
wash build | |
working-directory: cloud-hello | |
# Used later in the build process to push provenance info | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- uses: imjasonh/setup-crane@v0.1 | |
- name: Push | |
id: push | |
env: | |
WASH_REG_USER: ${{ github.repository_owner }} | |
WASH_REG_PASSWORD: ${{ secrets.GITHUB_TOKEN }} | |
WASH_ISSUER_KEY: ${{ secrets.COSMONIC_LABS_SIGNING_ACCOUNT}} | |
WASH_SUBJECT_KEY: ${{ secrets.CLOUD_HELLO_COMPONENT_KEY}} | |
run: | | |
if [ -z "$WASH_ISSUER_KEY" ]; then | |
echo "WASH_ISSUER_KEY is not set" | |
exit 1 | |
fi | |
wash push ${{env.REGISTRY}}/${{env.REPOSITORY}}/cloud-hello:$GITHUB_SHA build/cloud_hello_s.wasm | |
wash push ${{env.REGISTRY}}/${{env.REPOSITORY}}/cloud-hello:$(git rev-parse --short HEAD) build/cloud_hello_s.wasm | |
wash push ${{env.REGISTRY}}/${{env.REPOSITORY}}/cloud-hello:${{steps.ctx.outputs.version}} build/cloud_hello_s.wasm | |
digest=$(crane digest ${{env.REGISTRY}}/${{env.REPOSITORY}}/cloud-hello:$GITHUB_SHA) | |
echo "digest=$digest" >> "$GITHUB_OUTPUT" | |
shell: bash | |
working-directory: cloud-hello | |
- name: Generate artifact attestation | |
uses: actions/attest-build-provenance@v1 | |
with: | |
subject-name: ${{env.REGISTRY}}/${{env.REPOSITORY}}/cloud-hello | |
subject-digest: ${{ steps.push.outputs.digest }} | |
push-to-registry: true |