-
-
Notifications
You must be signed in to change notification settings - Fork 28
[#1918] Updated CI config to export and restore exported codebase only for artifact deployment. #1924
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[#1918] Updated CI config to export and restore exported codebase only for artifact deployment. #1924
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -199,6 +199,9 @@ jobs: | |||||||||||||||||||||||||||||
| - name: Process the codebase to run in CI | ||||||||||||||||||||||||||||||
| run: find . -name "docker-compose.yml" -print0 | xargs -0 -I {} sh -c "sed -i -e '/###/d' {} && sed -i -e 's/##//' {}" | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| - name: Load environment variables from .env | ||||||||||||||||||||||||||||||
| run: t=$(mktemp) && export -p >"${t}" && set -a && . ./.env && set +a && . "${t}" && env >> "$GITHUB_ENV" | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| - name: Validate Composer configuration | ||||||||||||||||||||||||||||||
| run: composer validate --strict | ||||||||||||||||||||||||||||||
| continue-on-error: ${{ vars.VORTEX_CI_COMPOSER_VALIDATE_IGNORE_FAILURE == '1' }} | ||||||||||||||||||||||||||||||
|
|
@@ -248,7 +251,7 @@ jobs: | |||||||||||||||||||||||||||||
| run: docker compose up -d | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| - name: Export built codebase | ||||||||||||||||||||||||||||||
| if: matrix.instance == 0 | ||||||||||||||||||||||||||||||
| if: matrix.instance == 0 && contains(env.VORTEX_DEPLOY_TYPES, 'artifact') | ||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||
| mkdir -p "/tmp/workspace/code" | ||||||||||||||||||||||||||||||
| docker compose cp -L cli:"/app/." "/tmp/workspace/code" | ||||||||||||||||||||||||||||||
|
|
@@ -362,7 +365,7 @@ jobs: | |||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| - name: Upload exported codebase as artifact | ||||||||||||||||||||||||||||||
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 | ||||||||||||||||||||||||||||||
| if: ${{ matrix.instance == 0 && !startsWith(github.head_ref || github.ref_name, 'deps/') }} | ||||||||||||||||||||||||||||||
| if: ${{ matrix.instance == 0 && !startsWith(github.head_ref || github.ref_name, 'deps/') && contains(env.VORTEX_DEPLOY_TYPES, 'artifact') }} | ||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||
| name: code-artifact | ||||||||||||||||||||||||||||||
| path: "/tmp/workspace/code" | ||||||||||||||||||||||||||||||
|
|
@@ -407,8 +410,12 @@ jobs: | |||||||||||||||||||||||||||||
| persist-credentials: false | ||||||||||||||||||||||||||||||
| ref: ${{ github.head_ref || github.ref_name }} | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| - name: Load environment variables from .env | ||||||||||||||||||||||||||||||
| run: t=$(mktemp) && export -p >"${t}" && set -a && . ./.env && set +a && . "${t}" && env >> "$GITHUB_ENV" | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
Comment on lines
+413
to
+415
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Repeat the safe .env loader here as well Same concerns as in the build job: avoid restoring the snapshot after sourcing .env and avoid dumping the whole environment to GITHUB_ENV. - - name: Load environment variables from .env
- run: t=$(mktemp) && export -p >"${t}" && set -a && . ./.env && set +a && . "${t}" && env >> "$GITHUB_ENV"
+ - name: Load environment variables from .env (safe)
+ run: |
+ while IFS='=' read -r key rest; do
+ [ -z "${key}" ] && continue
+ case "${key}" in \#* ) continue;; esac
+ key="${key%%[[:space:]]*}"
+ {
+ echo "${key}<<__ENV__"
+ printf '%s\n' "${rest}"
+ echo "__ENV__"
+ } >> "$GITHUB_ENV"
+ done < .env📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||
| - name: Download exported codebase as an artifact | ||||||||||||||||||||||||||||||
| uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5 | ||||||||||||||||||||||||||||||
| if: ${{ contains(env.VORTEX_DEPLOY_TYPES, 'artifact') }} | ||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||
| name: code-artifact | ||||||||||||||||||||||||||||||
| path: "/tmp/workspace/code" | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -273,5 +273,5 @@ jobs: | |||||
| continue-on-error: ${{ vars.VORTEX_CI_YAMLLINT_IGNORE_FAILURE == '1' }} | ||||||
|
|
||||||
| - name: Check coding standards with actionlint | ||||||
| run: docker run --rm -v "${GITHUB_WORKSPACE:-.}":/app --workdir /app rhysd/actionlint:1.7.2 -ignore 'SC2002:' -ignore 'SC2155:' -ignore 'SC2015:' -ignore 'SC2046:' | ||||||
| run: docker run --rm -v "${GITHUB_WORKSPACE:-.}":/app --workdir /app rhysd/actionlint:1.7.2 -ignore 'SC2002:' -ignore 'SC2155:' -ignore 'SC2015:' -ignore 'SC2046:' -ignore 'SC1090:' | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Avoid blanket-ignoring SC1090; eliminate the root cause instead SC1090 is triggered by sourcing .env in other workflows. Prefer switching those steps to a non-sourcing .env loader (parsing key=value and writing to GITHUB_ENV/BASH_ENV) which removes SC1090 entirely. Then drop this global ignore to keep signal from shellcheck high. If you keep SC1090 ignored here, scope it with a regex to only the specific jobs/files that need it, rather than every workflow. Once you adopt the safe loader in build-test-deploy.yml and CircleCI, you can safely apply: - run: docker run --rm -v "${GITHUB_WORKSPACE:-.}":/app --workdir /app rhysd/actionlint:1.7.2 -ignore 'SC2002:' -ignore 'SC2155:' -ignore 'SC2015:' -ignore 'SC2046:' -ignore 'SC1090:'
+ run: docker run --rm -v "${GITHUB_WORKSPACE:-.}":/app --workdir /app rhysd/actionlint:1.7.2 -ignore 'SC2002:' -ignore 'SC2155:' -ignore 'SC2015:' -ignore 'SC2046:'📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| continue-on-error: ${{ vars.VORTEX_CI_ACTIONLINT_IGNORE_FAILURE == '1' }} | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix unsafe/ineffective .env loader anchor; export only .env keys to $BASH_ENV
Current anchor:
Use a safe parser that writes only .env variables to $BASH_ENV with proper quoting. This also removes the need to ignore SC1090 elsewhere.
Apply:
- &load_variables_from_dotenv run: - name: Load environment variables from .env file - # Load variables from .env file, respecting existing values, and make them available for the next steps. - command: t=$(mktemp) && export -p >"${t}" && set -a && . ./.env && set +a && . "${t}" && export -p >> "$BASH_ENV" + name: Load environment variables from .env file (safe) + command: | + if [ -f .env ]; then + # Export only keys from .env; ignore comments/blank lines. + while IFS='=' read -r key rest; do + [ -z "${key}" ] && continue + case "${key}" in \#* ) continue;; esac + key="${key%%[[:space:]]*}" + # Safely quote for BASH_ENV + printf 'export %s=%q\n' "$key" "$rest" >> "$BASH_ENV" + done < .env + fi + # Optional: names-only debug + [ "${VORTEX_DEBUG:-}" = "1" ] && awk -F= '!/^($|#)/{print "Loaded: "$1}' .env || true📝 Committable suggestion
🤖 Prompt for AI Agents