Skip to content

Commit

Permalink
Update github workflow to latest skohub template
Browse files Browse the repository at this point in the history
  • Loading branch information
awagner-mainz authored Apr 10, 2024
1 parent 147f31d commit 75f82d3
Showing 1 changed file with 89 additions and 15 deletions.
104 changes: 89 additions & 15 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ name: Build /public and deploy to gh-pages with docker container

on:
push:
branches:
- main
- gh-pages
workflow_dispatch:
inputs:
logLevel:
Expand All @@ -13,14 +10,91 @@ on:
default: 'warning'
tags:
description: 'Test scenario tags'
required: false

jobs:
all-ttl-files:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.file-list }}
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Find TTL files
id: find-ttl
run: |
ttl_files=$(find . -name '*.ttl' -printf '"%p",' | sed 's/,$//')
echo "ttl_files=$ttl_files"
echo "ttl_files=$ttl_files" >> "$GITHUB_ENV"
- name: Set matrix for TTL files
id: set-matrix
run: echo "file-list=[${ttl_files}]" >> $GITHUB_OUTPUT

- name: List all changed files
run: echo "${ttl_files}"

changedfiles:
runs-on: ubuntu-latest
outputs:
ttl: ${{ steps.set-ttl-matrix.outputs.ttl }}
yml: ${{ steps.set-yml-matrix.outputs.yml }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Get changed ttl-files
id: changed-ttl-files
uses: tj-actions/changed-files@v42
with:
files: |
**/*.ttl
json: true

- name: Get changed yml-files
id: changed-yml-files
uses: tj-actions/changed-files@v42
with:
files: |
**/*.yml
**/*.yaml
json: true

- name: Set turtle file matrix
id: set-ttl-matrix
run: echo "ttl=${{ steps.changed-ttl-files.outputs.all_changed_files }}" >> $GITHUB_OUTPUT

- name: Set yml file matrix
id: set-yml-matrix
run: echo "yml=${{ steps.changed-yml-files.outputs.all_changed_files }}" >> $GITHUB_OUTPUT

prepare-matrix:
runs-on: ubuntu-latest
needs: [changedfiles, all-ttl-files]
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Determine matrix
id: set-matrix
run: |
changed_files_ttl=${{ toJSON(needs.changedfiles.outputs.ttl) }}
changed_files_yml=${{ toJSON(needs.changedfiles.outputs.yml) }}
if [ $(echo "$changed_files_ttl" | jq length) -gt 0 ]; then
echo "matrix=${{ toJSON(needs.changedfiles.outputs.ttl) }}" >> $GITHUB_OUTPUT
elif [ $(echo "$changed_files_yml" | jq length) -gt 0 ]; then
echo "matrix=${{ toJSON(needs.all-ttl-files.outputs.matrix) }}" >> $GITHUB_OUTPUT
else
echo "matrix=[]" >> $GITHUB_OUTPUT
fi
build:
runs-on: ubuntu-latest
needs: [prepare-matrix]
if: ${{ needs.prepare-matrix.outputs.matrix != '[]'}}
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4 # If you're using actions/checkout@v2 you must set persist-credentials to false in most cases for the deployment to work correctly.
uses: actions/checkout@v2 # If you're using actions/checkout@v2 you must set persist-credentials to false in most cases for the deployment to work correctly.
with:
persist-credentials: false

Expand All @@ -29,28 +103,28 @@ jobs:

- run: mkdir public

- run: mkdir data
- run: chmod -R 777 public # user in container is node which won't have write access to public

- run: chmod -R 2777 data # user in container is node which won't have write access to public

- run: chmod -R 2777 public # user in container is node which won't have write access to public
- run: mkdir data

- run: git clone https://github.com/mpilhlt/vocabs-worktime.git data/
- run: chmod -R 777 data # user in container is node which won't have write access to public

- name: make .env.production file
run: echo "BASEURL=/vocabs-worktime" > .env.production
- run: git clone https://github.com/$GITHUB_REPOSITORY.git data/

- name: make .env file
run: echo "BASEURL=/vocabs-worktime" > .env
run: |
input=$GITHUB_REPOSITORY
repo=${input#*/}
echo "BASEURL=/$repo" > .env
- name: build public dir with docker image
run: >
docker run
-v $(pwd)/public:/app/public
-v $(pwd)/data:/app/data
-v $(pwd)/.env.production:/app/.env.production
-v $(pwd)/.env:/app/.env
-e GATSBY_RESPOSITORY_URL=https://github.com/skohub-io/skohub-docker-vocabs.git
-v $(pwd)/config.yaml:/app/config.yaml
-e GATSBY_RESPOSITORY_URL=https://github.com/$GITHUB_REPOSITORY
skohub/skohub-vocabs-docker:latest
- name: Deploy
Expand Down

0 comments on commit 75f82d3

Please sign in to comment.