Prep 4 s3 Deploy[2]: Echo Changed files array.len #34
Workflow file for this run
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
# @file: prep_3_s3_deploy.yml | |
# This actions will (force) push changes to deploy-branches if the corresponding config file changes | |
# | |
# Attached resources: | |
# - Github SECRETS: | |
# | |
# - Github VARIABLES: | |
# | |
# | |
name: "(Force) Push Changes to deploy-branches" | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
jobs: | |
Deploy: | |
runs-on: ubuntu-20.04 | |
defaults: | |
run: | |
shell: bash | |
steps: | |
- name: Checkout the repository | |
uses: actions/checkout@v4 | |
- name: Set Variables | |
run: | | |
echo "TESTING - Set Variable" | |
echo "SRC_DEV=0" >> "${GITHUB_ENV}" | |
echo "SRC_TEST=0" >> "${GITHUB_ENV}" | |
echo "SRC_PROD=0" >> "${GITHUB_ENV}" | |
echo "SRC_TEST = $GITHUB_ENV.SRC_TEST" | |
# - name: Dump GitHub context | |
# env: | |
# GITHUB_CONTEXT: ${{ toJson(github) }} | |
# run: echo "$GITHUB_CONTEXT" | |
# - name: Dump job context | |
# env: | |
# JOB_CONTEXT: ${{ toJson(job) }} | |
# run: echo "$JOB_CONTEXT" | |
# - name: Dump steps context | |
# env: | |
# STEPS_CONTEXT: ${{ toJson(steps) }} | |
# run: echo "$STEPS_CONTEXT" | |
# - name: Dump runner context | |
# env: | |
# RUNNER_CONTEXT: ${{ toJson(runner) }} | |
# run: echo "$RUNNER_CONTEXT" | |
- name: Get all changed config files | |
id: changed-config-files | |
uses: tj-actions/changed-files@v44 | |
with: | |
# Avoid using single or double quotes for multiline patterns | |
files: | | |
**.yaml | |
- name: List all changed files config files | |
if: steps.changed-config-files.outputs.any_changed == 'true' | |
env: | |
ALL_CHANGED_FILES: ${{ steps.changed-config-files.outputs.all_changed_files }} | |
GITHUB_CONTEXT: ${{ toJson(github) }} | |
run: | | |
echo "TARGET_BRANCH='deploy-none'" >> "${GITHUB_ENV}" | |
TARGET=deploy-none | |
for file in ${ALL_CHANGED_FILES}; do | |
echo "$file was changed" | |
if [[ $file == src/configs/test/apps.yaml ]] | |
then | |
echo "SRC_TEST=1" >> "${GITHUB_ENV}" | |
echo "TARGET_BRANCH='deploy-test'" >> "${GITHUB_ENV}" | |
TARGET=deploy-test | |
fi | |
if [[ $file == src/configs/dev/apps.yaml ]] | |
then | |
echo "TARGET_BRANCH='deploy-dev'" >> "${GITHUB_ENV}" | |
TARGET=deploy-dev | |
fi | |
if [[ $file == src/configs/prod/apps.yaml ]] | |
then | |
echo "TARGET_BRANCH='deploy-prod'" >> "${GITHUB_ENV}" | |
TARGET=deploy-prod | |
fi | |
echo "TARGET_BRANCH Below:" | |
echo "${{ env.TARGET_BRANCH }} | $TARGET | ${TARGET}" | |
echo "Actor: $GITHUB_CONTEXT.actor" | |
done | |
echo "ALL_CHANGED_FILES.len = ${#ALL_CHANGED_FILES[@]}" | |
# - name: Check if deploy is needed | |
# env: | |
# GITHUB_ENV: ${{ toJson(env) }} | |
# # run: echo "$GITHUB_ENV.SRC_TEST" | |
# run: | | |
# if [[ ${{ env.SRC_TEST }} == 1 ]] | |
# then | |
# echo "SRC_TEST 1" | |
# echo "${{ env.SRC_TEST }}" | |
# else | |
# echo "SRC_TEST 0" | |
# echo "${{ env.SRC_TEST }}" | |
# fi | |
# - name: Dump GitHub Env | |
# env: | |
# GITHUB_ENV: ${{ toJson(env) }} | |
# run: echo "$GITHUB_ENV | |
# - name: Dump GitHub context | |
# env: | |
# GITHUB_CONTEXT: ${{ toJson(github) }} | |
# run: echo "$GITHUB_CONTEXT" | |
# - name: Dump job context | |
# env: | |
# JOB_CONTEXT: ${{ toJson(job) }} | |
# run: echo "$JOB_CONTEXT" | |
# - name: Dump steps context | |
# env: | |
# STEPS_CONTEXT: ${{ toJson(steps) }} | |
# run: echo "$STEPS_CONTEXT" | |
# - name: Dump runner context | |
# env: | |
# RUNNER_CONTEXT: ${{ toJson(runner) }} | |
# run: echo "$RUNNER_CONTEXT" | |
# - uses: jitterbit/get-changed-files@v1 | |
# id: abc | |
# with: | |
# format: space-delimited | |
# token: ${{ secrets.GITHUB_TOKEN }} | |
# - name: Printing | |
# run: | | |
# echo "All:" | |
# echo "${{ steps.abc.outputs.all }}" | |
# echo "Added:" | |
# echo "${{ steps.abc.outputs.added }}" | |
# echo "Removed:" | |
# echo "${{ steps.abc.outputs.removed }}" | |
# echo "Renamed:" | |
# echo "${{ steps.abc.outputs.renamed }}" | |
# echo "Modified:" | |
# echo "${{ steps.abc.outputs.modified }}" | |
# echo "Added+Modified:" | |
# echo "${{ steps.abc.outputs.added_modified }}" |