read env config file only when update job, pipeline #5
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: Build and deploy on prod | |
on: | |
push: | |
branches: | |
- 'main' # matches only main | |
env: | |
CI_COMMIT_MESSAGE: ${{ github.event.head_commit.message }} | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: checkout repo content | |
uses: actions/checkout@v4 # checkout the repository content | |
- name: setup python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' # install the python version needed | |
- name: install required python librairies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r cicd_saagie_tool/requirements.txt | |
- name: Get specific changed files | |
id: changed-files-specific | |
uses: tj-actions/changed-files@v37 # check if we have file changed | |
with: | |
files_yaml: | | |
jobs: | |
- saagie/jobs/*.json | |
pipelines: | |
- saagie/pipelines/*.json | |
- name: Run step if any of the jobs files above change | |
if: steps.changed-files-specific.outputs.jobs_any_changed == 'true' # check if a job config file have change | |
# then it will package the job and update on Saagie | |
run: | | |
for file in ${{ steps.changed-files-specific.outputs.jobs_all_changed_files }}; do | |
echo "$file was modified" | |
file_name=$(basename ${file}) | |
file_name_without_ext=${file_name%.*} | |
python cicd_saagie_tool/__main__.py --action package_job --job_name ${file_name_without_ext} | |
python cicd_saagie_tool/__main__.py --action update_job --job_name ${file_name_without_ext} --saagie_url "${{secrets.SAAGIE_URL}}" --saagie_user "${{secrets.SAAGIE_USER}}" --saagie_pwd "${{secrets.SAAGIE_PWD}}" --saagie_realm "${{secrets.SAAGIE_REALM}}}" --saagie_env prod | |
done | |
- name: Run step if any of the pipelines files above change | |
if: steps.changed-files-specific.outputs.pipelines_any_changed == 'true' # check if a pipeline config file have change | |
# then it will update on Saagie | |
run: | | |
for file in ${{ steps.changed-files-specific.outputs.pipelines_all_changed_files }}; do | |
echo "$file was modified" | |
file_name=$(basename ${file}) | |
file_name_without_ext=${file_name%.*} | |
python cicd_saagie_tool/__main__.py --action update_pipeline --pipeline_name ${file_name_without_ext} --saagie_url "${{secrets.SAAGIE_URL}}" --saagie_user "${{secrets.SAAGIE_USER}}" --saagie_pwd "${{secrets.SAAGIE_PWD}}" --saagie_realm "${{secrets.SAAGIE_REALM}}" --saagie_env prod | |
done |