Adding OWP first version #14
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: push_on_tag_dev_workflow | |
on: | |
push: | |
branches: | |
- '!main' | |
paths: | |
- 'charts/**' | |
- 'salt/**' | |
- 'config/**' | |
- '**.Dokerfile' | |
- 'snow-inspector/**' | |
- 'tethysapp-hydrocompute/**' | |
- 'tethysapp-metdataexplorer/**' | |
- 'tethysapp-swe/**' | |
- 'tethysapp-tethys_app_store/**' | |
- 'tethysext-ciroh_theme/**' | |
- 'Water-Data-Explorer/**' | |
- 'OWP/**' | |
pull_request: | |
branches: | |
- main | |
paths: | |
- 'charts/**' | |
- 'salt/**' | |
- 'config/**' | |
- '**.Dokerfile' | |
- 'snow-inspector/**' | |
- 'tethysapp-hydrocompute/**' | |
- 'tethysapp-metdataexplorer/**' | |
- 'tethysapp-swe/**' | |
- 'tethysapp-tethys_app_store/**' | |
- 'tethysext-ciroh_theme/**' | |
- 'Water-Data-Explorer/**' | |
- 'OWP/**' | |
env: | |
IMAGE_TAG: dev_${GITHUB_SHA} | |
DOCKER_HUB_ORG: gioelkin | |
# DOCKER_HUB_ORG: ciroh | |
DOCKER_REPO: tethysapp-ciroh-portal | |
MAX_NUMBER_IMAGE: 5 | |
jobs: | |
build: | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 2 | |
submodules: 'true' | |
# Checks-out the hydrocompute extra submodule | |
- name: checkout Hydrocompute submodule | |
run: | | |
cd tethysapp-hydrocompute/tethysapp/hydrocompute/public/HydroCompute && git submodule update --init --recursive | |
- name: Set Tag | |
run: | | |
echo "TAG=${{ env.IMAGE_TAG }}" >> $GITHUB_ENV | |
# If the branch is stable, we'll overwrite the TAG to include stable. | |
- name: Set Stable Tag | |
if: endsWith(github.ref, '/stable') | |
run: | | |
echo "TAG=stable" >> $GITHUB_ENV | |
- name: Test Tag | |
run: | | |
echo $TAG | |
- name: check_docker_file_changed_files | |
id: changed-files-yaml | |
uses: tj-actions/changed-files@v37 | |
with: | |
files_yaml: | | |
docker: | |
- salt/** | |
- prod.Dockerfile | |
- piprequirements.txt | |
- config/** | |
- .gitmodules | |
- snow-inspector/** | |
- tethysapp-hydrocompute/** | |
- tethysapp-metdataexplorer/** | |
- tethysapp-swe/** | |
- tethysapp-tethys_app_store/** | |
- tethysext-ciroh_theme/** | |
- Water-Data-Explorer/** | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_BUILDER_USERNAME }} | |
password: ${{ secrets.DOCKER_BUILDER_TOKEN }} | |
- name: build and push tag | |
uses: docker/build-push-action@v4 | |
if: steps.changed-files-yaml.outputs.docker_any_changed == 'true' | |
with: | |
context: . | |
file: ./prod.Dockerfile | |
push: true | |
tags: ${{ env.DOCKER_HUB_ORG }}/${{ env.DOCKER_REPO }}:${{ env.TAG }} | |
cache-from: type=registry,ref=${{ env.DOCKER_HUB_ORG }}/${{ env.DOCKER_REPO }}-cache:latest | |
cache-to: type=registry,ref=${{ env.DOCKER_HUB_ORG }}/${{ env.DOCKER_REPO }}-cache:latest,mode=max | |
startup_test: | |
needs: [build] | |
runs-on: ubuntu-latest | |
services: | |
db: | |
image: postgis/postgis | |
env: | |
POSTGRES_HOST: db | |
POSTGRES_PASSWORD: passpass | |
POSTGRES_DB: tethys_postgis | |
POSTGRES_PORT: 5432 | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 10 | |
ports: | |
- 5432:5432 | |
steps: | |
- name: Check out repository code | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 2 | |
- name: check_docker_file_changed_files | |
id: changed-files-yaml | |
uses: tj-actions/changed-files@v37 | |
with: | |
files_yaml: | | |
docker: | |
- salt/** | |
- prod.Dockerfile | |
- piprequirements.txt | |
- config/** | |
- .gitmodules | |
- snow-inspector/** | |
- tethysapp-hydrocompute/** | |
- tethysapp-metdataexplorer/** | |
- tethysapp-swe/** | |
- tethysapp-tethys_app_store/** | |
- tethysext-ciroh_theme/** | |
- Water-Data-Explorer/** | |
- name: Docker login | |
if: steps.changed-files-yaml.outputs.docker_any_changed == 'true' | |
run: docker login -u ${{ secrets.DOCKER_BUILDER_USERNAME }} -p ${{ secrets.DOCKER_BUILDER_TOKEN }} | |
- name: Pull Docker Image | |
if: steps.changed-files-yaml.outputs.docker_any_changed == 'true' | |
run: | | |
docker pull ${{ env.DOCKER_HUB_ORG }}/${{ env.DOCKER_REPO }}:${{ env.IMAGE_TAG }} | |
- name: Run Salt Test | |
if: steps.changed-files-yaml.outputs.docker_any_changed == 'true' | |
run: | | |
docker run --rm --name ciroh_portal --network ${{ job.services.db.network }} --env-file env/web.env ${{ env.DOCKER_HUB_ORG }}/${{ env.DOCKER_REPO }}:${{ env.IMAGE_TAG }} /bin/bash -c "cd /usr/lib/tethys && source ./run.sh --test" | |
cleanup: | |
needs: [build] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: only keeps the first 5 image | |
run: | | |
echo "TAG=dev_${GITHUB_SHA}" >> $GITHUB_ENV | |
echo $TAG | |
. .github/scripts/clean_up_docker_hub.sh '${{ secrets.DOCKER_BUILDER_USERNAME }}' '${{ secrets.DOCKER_BUILDER_TOKEN }}' '${{ env.DOCKER_HUB_ORG }}' '${{ env.DOCKER_REPO }}' '${{ env.MAX_NUMBER_IMAGE }}' | |
#https://stackoverflow.com/questions/70959792/how-to-run-github-action-job-after-all-conditional-jobs-even-its-didnt-ran | |
lint-test: | |
runs-on: ubuntu-latest | |
needs: [startup_test] | |
if: | | |
always() && | |
!contains(needs.*.result, 'failure') && | |
!cancelled() | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 2 | |
- name: check_chart_file_changed_files | |
id: changed-chart-files-yaml | |
uses: tj-actions/changed-files@v37 | |
with: | |
files_yaml: | | |
charts: | |
- charts/** | |
- name: Set up Helm | |
if: steps.changed-chart-files-yaml.outputs.charts_any_changed == 'true' | |
uses: azure/setup-helm@v3 | |
with: | |
version: v3.6.3 | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Python | |
if: steps.changed-chart-files-yaml.outputs.charts_any_changed == 'true' | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.7 | |
- name: Set up chart-testing | |
if: steps.changed-chart-files-yaml.outputs.charts_any_changed == 'true' | |
uses: helm/[email protected] | |
- name: Run chart-testing (list-changed) | |
if: steps.changed-chart-files-yaml.outputs.charts_any_changed == 'true' | |
id: list-changed | |
run: | | |
## If executed with debug this won't work anymore. | |
changed=$(ct --config .github/config/ct.yaml list-changed) | |
charts=$(echo "$changed" | tr '\n' ' ' | xargs) | |
if [[ -n "$changed" ]]; then | |
echo "::set-output name=changed::true" | |
echo "::set-output name=changed_charts::$charts" | |
fi | |
- name: Run Artifact Hub lint | |
if: steps.changed-chart-files-yaml.outputs.charts_any_changed == 'true' | |
run: | | |
curl -s https://api.github.com/repos/artifacthub/hub/releases/latest | grep -E 'browser_download_url' | grep linux_amd64.tar.gz\" | grep -Eo 'https://[^\"]*' | xargs wget -O - | tar -xz | |
./ah lint -p charts/ciroh || exit 1 | |
rm -f ./ah | |
- name: Run chart-testing (lint) | |
if: steps.changed-chart-files-yaml.outputs.charts_any_changed == 'true' | |
run: ct lint --debug --config .github/config/ct.yaml | |
## Might need to be uncommented when the testing gets resolved: | |
## the testing fails for two reasons the TDS services does never gets scheduled | |
## the automatization of the geoserver does not work and the salt job is failling | |
# - name: Create kind cluster | |
# uses: helm/[email protected] | |
# if: steps.list-changed.outputs.changed == 'true' | |
# - name: Run chart-testing (install) | |
# run: ct install --debug --config .github/config/ct.yaml | |
# if: steps.list-changed.outputs.changed == 'true' |