Export Data #16
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: Export Data | |
on: | |
release: | |
types: [published] | |
workflow_dispatch: | |
env: | |
OPENBIS_V3: https://localhost:8128/openbis/openbis/rmi-application-server-v3.json | |
OPENBISMANTIC_API: https://localhost:8128/openbismantic | |
SAMPLE_TYPE: EXPERIMENTAL_STEP_EMODUL | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
repository: ${{ github.event.pull_request.head.repo.full_name }} | |
ref: ${{ github.event.pull_request.head.ref }} | |
submodules: recursive | |
- name: run app | |
run: | | |
touch .env | |
echo ADMIN_PASS=example >> .env | |
echo OBSERVER_PASS=example >> .env | |
echo HOST_NAME=127.0.0.1 >> .env | |
echo OPENBIS_PORT=8127 >> .env | |
echo OPENBIS_SSL_PORT=8128 >> .env | |
echo POSTGRES_PASSWORD=example >> .env | |
echo GROUP_NAME=openbis >> .env | |
echo GROUP_ID=1000 >> .env | |
echo OPENBISMANTIC_URL=https://openbis.matolab.org >> .env | |
docker compose up -d | |
docker compose logs -f init_database | |
- name: Update exported data | |
run: | | |
rm -rf exported_data | |
mkdir -p exported_data | |
token=$(curl -sk -d "{\"method\": \"login\", \"params\": [\"admin\", \"example\"], \"id\": \"1\", \"jsonrpc\": \"2.0\"}" ${{env.OPENBIS_V3}} | jq -r '.result') | |
if [[ $token == "null" ]] | |
then | |
echo "failed to log in" | |
exit 1 | |
fi | |
echo "logged in successfully" | |
permIds=$(curl -sk -d "{\"method\":\"searchSamples\",\"params\":[\"${token}\",{\"@id\":0,\"criteria\":[{\"@id\":1,\"criteria\":[{\"@id\":2,\"fieldName\":\"code\",\"fieldType\":\"ATTRIBUTE\",\"fieldValue\":{\"@id\":3,\"value\":\"${{env.SAMPLE_TYPE}}\",\"@type\":\"as.dto.common.search.StringEqualToValue\"},\"useWildcards\":false,\"@type\":\"as.dto.common.search.CodeSearchCriteria\"}],\"@type\":\"as.dto.sample.search.SampleTypeSearchCriteria\",\"operator\":\"AND\"}],\"relation\":\"SAMPLE\",\"operator\":\"AND\",\"negated\":false,\"@type\":\"as.dto.sample.search.SampleSearchCriteria\"},{\"type\": {\"@type\": \"as.dto.sample.fetchoptions.SampleTypeFetchOptions\"}}],\"id\":\"1\",\"jsonrpc\":\"2.0\"}" ${{env.OPENBIS_V3}} | jq -r '[.result.objects[].permId.permId]|join(" ")') | |
echo "found samples ${permIds}" | |
for permId in $permIds | |
do | |
result=$(curl -sk -H "Cookie: openbis=${token}" "${{env.OPENBISMANTIC_API}}/object/${permId}") | |
echo $result >> "exported_data/${permId}.json" | |
done | |
- name: commit results | |
uses: EndBug/add-and-commit@v9 | |
with: | |
message: 'update exported data' | |
add: '*.* --force' | |
cwd: './exported_data/' |