Updated main.yaml

This commit is contained in:
Brage 2023-07-21 00:23:51 +02:00
parent 9065b56100
commit f0381ec10e

View File

@ -12,46 +12,29 @@ on:
jobs: jobs:
pre-check: pre-check:
runs-on: ubuntu-latest runs-on: ubuntu-latest
outputs:
pyMetadata: ${{ steps.filter.outputs.pyMetadata }}
commonCode: ${{ steps.filter.outputs.commonCode }}
reader: ${{ steps.filter.outputs.reader }}
encode: ${{ steps.filter.outputs.encode }}
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Select jobs - uses: dorny/paths-filter@v2
run: | id: filter
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then with:
echo "job_run_pyMetadata=true" >> "$GITHUB_ENV" filters: |
echo "job_run_commonCode=true" >> "$GITHUB_ENV" pyMetadata:
echo "job_run_reader=true" >> "$GITHUB_ENV" - 'pyMetadata/**'
echo "job_run_encode=true" >> "$GITHUB_ENV" reader:
else - 'Reader/**'
# Checks pyMetadata for changes encode:
if [[ $(git diff --name-only ${{ github.event.before }} ${{ github.sha }} pyMetadata/) ]]; then - 'Encode/**'
echo "job_run_pyMetadata=true" >> "$GITHUB_ENV" commonCode:
else - 'CommonCode/**'
echo "job_run_pyMetadata=false" >> "$GITHUB_ENV"
fi
# Checks CommonCode for changes
if [[ $(git diff --name-only ${{ github.event.before }} ${{ github.sha }} CommonCode/) ]]; then
echo "job_run_commonCode=true" >> "$GITHUB_ENV"
else
echo "job_run_commonCode=false" >> "$GITHUB_ENV"
fi
# Checks Reader for changes
if [[ $(git diff --name-only ${{ github.event.before }} ${{ github.sha }} Reader/) ]]; then
echo "job_run_reader=true" >> "$GITHUB_ENV"
else
echo "job_run_reader=false" >> "$GITHUB_ENV"
fi
# Checks Encode for changes
if [[ $(git diff --name-only ${{ github.event.before }} ${{ github.sha }} Encode/) ]]; then
echo "job_run_encode=true" >> "$GITHUB_ENV"
else
echo "job_run_encode=false" >> "$GITHUB_ENV"
fi
fi
build-commoncode: build-commoncode:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -60,17 +43,7 @@ jobs:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Check if code has changed
id: check-commoncode
run: |
if [[ $(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} CommonCode/) ]]; then
echo "::set-output name=skip::false"
else
echo "::set-output name=skip::true"
fi
- name: Cache CommonCode Gradle dependencies - name: Cache CommonCode Gradle dependencies
if: steps.check-commoncode.outputs.skip == 'false'
id: cache-gradle id: cache-gradle
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
@ -86,6 +59,7 @@ jobs:
build-encode: build-encode:
needs: build-commoncode needs: build-commoncode
if: ${{ needs.changes.outputs.encode == 'true' || github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
#if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }} #if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
@ -94,7 +68,6 @@ jobs:
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Cache CommonCode Gradle dependencies - name: Cache CommonCode Gradle dependencies
if: env.job_run_encode == 'true'
id: cache-gradle id: cache-gradle
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
@ -103,7 +76,6 @@ jobs:
- name: Build Encode module - name: Build Encode module
if: env.job_run_encode == 'true'
id: build-encode id: build-encode
run: | run: |
cd Encode cd Encode
@ -113,19 +85,16 @@ jobs:
- name: Generate Docker image tag - name: Generate Docker image tag
if: env.job_run_encode == 'true'
id: docker-tag id: docker-tag
run: echo "::set-output name=tag::$(date -u +'%Y.%m.%d')-$(uuidgen | cut -c 1-8)" run: echo "::set-output name=tag::$(date -u +'%Y.%m.%d')-$(uuidgen | cut -c 1-8)"
- name: Docker login - name: Docker login
if: env.job_run_encode == 'true'
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with: with:
username: ${{ secrets.DOCKER_HUB_NAME }} username: ${{ secrets.DOCKER_HUB_NAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }} password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Build and push Docker image - name: Build and push Docker image
if: env.job_run_encode == 'true'
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
with: with:
context: ./Encode context: ./Encode
@ -138,14 +107,13 @@ jobs:
build-reader: build-reader:
needs: build-commoncode needs: build-commoncode
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: ${{ needs.changes.outputs.reader == 'true' || github.event_name == 'workflow_dispatch' }}
steps: steps:
- name: Checkout repository - name: Checkout repository
if: env.job_run_reader == 'true'
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Cache CommonCode Gradle dependencies - name: Cache CommonCode Gradle dependencies
if: env.job_run_reader == 'true'
id: cache-gradle id: cache-gradle
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
@ -154,7 +122,6 @@ jobs:
- name: Build Reader module - name: Build Reader module
id: build-reader id: build-reader
if: env.job_run_reader == 'true'
run: | run: |
cd Reader cd Reader
chmod +x ./gradlew chmod +x ./gradlew
@ -162,19 +129,16 @@ jobs:
echo "Build completed" echo "Build completed"
- name: Generate Docker image tag - name: Generate Docker image tag
if: env.job_run_reader == 'true'
id: docker-tag id: docker-tag
run: echo "::set-output name=tag::$(date -u +'%Y.%m.%d')-$(uuidgen | cut -c 1-8)" run: echo "::set-output name=tag::$(date -u +'%Y.%m.%d')-$(uuidgen | cut -c 1-8)"
- name: Docker login - name: Docker login
if: env.job_run_reader == 'true'
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with: with:
username: ${{ secrets.DOCKER_HUB_NAME }} username: ${{ secrets.DOCKER_HUB_NAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }} password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Build and push Docker image - name: Build and push Docker image
if: env.job_run_reader == 'true'
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
with: with:
context: ./Reader context: ./Reader
@ -188,16 +152,15 @@ jobs:
build-pymetadata: build-pymetadata:
needs: pre-check needs: pre-check
if: ${{ needs.changes.outputs.pyMetadata == 'true' || github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout repository - name: Checkout repository
if: env.job_run_pyMetadata == 'true'
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Build pyMetadata module - name: Build pyMetadata module
id: build-pymetadata id: build-pymetadata
if: env.job_run_pyMetadata == 'true'
run: | run: |
if [[ "${{ steps.check-pymetadata.outputs.changed }}" == "true" || "${{ github.event_name }}" == "push" || "${{ github.event_name }}" == "workflow_dispatch" ]]; then if [[ "${{ steps.check-pymetadata.outputs.changed }}" == "true" || "${{ github.event_name }}" == "push" || "${{ github.event_name }}" == "workflow_dispatch" ]]; then
cd pyMetadata cd pyMetadata
@ -209,19 +172,16 @@ jobs:
fi fi
- name: Generate Docker image tag - name: Generate Docker image tag
if: env.job_run_pyMetadata == 'true'
id: docker-tag id: docker-tag
run: echo "::set-output name=tag::$(date -u +'%Y.%m.%d')-$(uuidgen | cut -c 1-8)" run: echo "::set-output name=tag::$(date -u +'%Y.%m.%d')-$(uuidgen | cut -c 1-8)"
- name: Docker login - name: Docker login
if: env.job_run_pyMetadata == 'true'
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with: with:
username: ${{ secrets.DOCKER_HUB_NAME }} username: ${{ secrets.DOCKER_HUB_NAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }} password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Build and push Docker image - name: Build and push Docker image
if: env.job_run_pyMetadata == 'true'
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
with: with:
context: ./pyMetadata context: ./pyMetadata