Merge pull request #311 from skohub-io/309-deeper-hierarchy #7
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: Build | |
on: push | |
env: | |
IMAGE_NAME: ${{ github.repository }} | |
TEST_TAG: user/app:test | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [18.x] | |
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/ | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- run: echo Using node version $(node --version) | |
- run: echo Using npm version $(npm --version) | |
- run: cp .env.example .env | |
- run: cp test/data/ttl/interactivityType.ttl data/ | |
- name: Cache node modules | |
id: cache-npm | |
uses: actions/cache@v3 | |
env: | |
cache-name: cache-node-modules | |
with: | |
# npm cache files are stored in `~/.npm` on Linux/macOS | |
path: ~/.npm | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
${{ runner.os }}-build- | |
${{ runner.os }}- | |
- if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }} | |
name: List the state of node modules | |
continue-on-error: true | |
run: npm list | |
- run: npm install | |
- run: npm run build --if-present | |
- run: npm run test | |
# disables because the action fails on github action but tests works locally | |
e2e: | |
runs-on: ubuntu-22.04 | |
container: | |
image: cypress/browsers:node-20.9.0-chrome-118.0.5993.88-1-ff-118.0.2-edge-118.0.2088.46-1 | |
strategy: | |
matrix: | |
node-version: [18.x] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- run: echo Using node version $(node --version) | |
- run: echo Using npm version $(npm --version) | |
- run: cypress/prepare-cypress-test.sh | |
- name: Cypress run | |
uses: cypress-io/github-action@v6 | |
with: | |
headed: true | |
start: npm run develop -- -p 8000 | |
wait-on: 'http://0.0.0.0:8000' # see https://github.com/cypress-io/github-action#wait-on-with-nodejs-18 | |
config: baseUrl=http://localhost:8000 | |
docker: | |
needs: [build, e2e] | |
if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: skohub/skohub-vocabs-docker | |
tags: | | |
# set latest tag for default branch | |
type=raw,value=latest,enable={{is_default_branch}}# | |
type=raw,value=dev,enable=${{ github.ref == format('refs/heads/{0}', 'dev') }} | |
- name: Build and export to Docker | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
load: true | |
tags: ${{ env.TEST_TAG }} | |
- name: Test docker image | |
run: | | |
mkdir -p data | |
cp .env.example .env | |
cp test/data/ttl/interactivityType.ttl data/ | |
docker run --rm -v $(pwd)/data:/app/data -v $(pwd)/.env:/app/.env ${{ env.TEST_TAG }} | |
- name: Build and push | |
uses: docker/build-push-action@v3 | |
with: | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} |