Updated main.yaml

This commit is contained in:
Brage 2023-07-21 00:06:33 +02:00
parent 03e0363ef0
commit 9065b56100

View File

@ -87,23 +87,14 @@ jobs:
build-encode: build-encode:
needs: build-commoncode needs: build-commoncode
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: false
#if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }} #if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Check if Encode has changed
id: check-encode
run: |
if [[ $(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} Encode/) ]]; then
echo "::set-output name=changed::true"
else
echo "::set-output name=changed::false"
fi
- 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:
@ -112,30 +103,29 @@ jobs:
- name: Build Encode module - name: Build Encode module
if: env.job_run_encode == 'true'
id: build-encode id: build-encode
run: | run: |
if [[ "${{ steps.check-encode.outputs.changed }}" == "true" || "${{ github.event_name }}" == "push" || "${{ github.event_name }}" == "workflow_dispatch" ]]; then cd Encode
cd Encode chmod +x ./gradlew
chmod +x ./gradlew ./gradlew build
./gradlew build echo "Build completed"
echo "Build completed"
else
echo "Encode has not changed. Skipping Encode module build."
echo "::set-output name=job_skipped::true"
fi
- 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: (steps.build-encode.outputs.job_skipped != 'true' && github.event_name == 'push') || github.event_name == 'workflow_dispatch' if: env.job_run_encode == 'true'
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
with: with:
context: ./Encode context: ./Encode
@ -148,22 +138,14 @@ jobs:
build-reader: build-reader:
needs: build-commoncode needs: build-commoncode
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: env.job_run_reader == 'true'
steps: steps:
- name: Checkout repository - name: Checkout repository
if: env.job_run_reader == 'true'
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Check if Reader has changed
id: check-reader
run: |
if [[ $(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} Reader/) ]]; then
echo "::set-output name=changed::true"
else
echo "::set-output name=changed::false"
fi
- 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:
@ -172,29 +154,27 @@ jobs:
- name: Build Reader module - name: Build Reader module
id: build-reader id: build-reader
if: env.job_run_reader == 'true'
run: | run: |
if [[ "${{ steps.check-reader.outputs.changed }}" == "true" || "${{ github.event_name }}" == "push" || "${{ github.event_name }}" == "workflow_dispatch" ]]; then cd Reader
cd Reader chmod +x ./gradlew
chmod +x ./gradlew ./gradlew build
./gradlew build echo "Build completed"
echo "Build completed"
else
echo "Reader has not changed. Skipping Reader module build."
echo "::set-output name=job_skipped::true"
fi
- 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: (steps.build-reader.outputs.job_skipped != 'true' && github.event_name == 'push') || github.event_name == 'workflow_dispatch' if: env.job_run_reader == 'true'
uses: docker/build-push-action@v2 uses: docker/build-push-action@v2
with: with:
context: ./Reader context: ./Reader
@ -208,16 +188,16 @@ jobs:
build-pymetadata: build-pymetadata:
needs: pre-check needs: pre-check
if: env.job_run_pyMetadata == 'true'
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: steps.check-pymetadata.outputs.skip == 'false' # skip dette trinnet hvis pyMetadata ikke har endringer 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
@ -229,16 +209,19 @@ 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