fabric-samples/.github/workflows/rest-sample.yaml
Josh Kneubuhl 8eb484034c test build
Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
2022-11-15 08:24:15 -05:00

85 lines
No EOL
2.5 KiB
YAML

#
# SPDX-License-Identifier: Apache-2.0
#
name: REST Sample
run-name: ${{ github.actor }} is testing the REST Sample
env:
NODE_VER: 16.x
IMAGE_NAME: ghcr.io/hyperledger/fabric-rest-sample
on:
workflow_dispatch:
push:
branches: [ "main" ]
paths: [ "asset-transfer-basic/rest-api-typescript/**" ]
pull_request:
branches: [ "main" ]
paths: [ "asset-transfer-basic/rest-api-typescript/**" ]
jobs:
test-sample:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VER }}
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
- name: Install REST Sample Dependencies
working-directory: asset-transfer-basic/rest-api-typescript
run: npm install
- name: Build REST Sample Application
run: npm run build
working-directory: asset-transfer-basic/rest-api-typescript
- name: Test REST Sample Application
run: npm test
working-directory: asset-transfer-basic/rest-api-typescript
docker-image:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
${{ env.IMAGE_NAME }}
# todo: where shall we describe the revision of the sample component(s)?
# tags: |
# type=semver,pattern={{version}}
# type=semver,pattern={{major}}
# type=semver,pattern={{major}}.{{minor}}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
id: push
uses: docker/build-push-action@v3
with:
context: asset-transfer-basic/rest-api-typescript
platforms: linux/amd64,linux/arm64
# todo: this is not right as it may try to publish on any push event
# push: ${{ github.event_name != 'pull_request' }}
# todo: temp hack
push: ${{ github.event_name == 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}