update trigger.yml: Ensure json string is stored as a string #79
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
name: Build Trigger | |
on: | |
pull_request: | |
types: | |
- opened | |
- synchronize | |
- reopened | |
- closed | |
branches: | |
- main | |
paths: | |
- ".github/workflows/trigger.yml" | |
- "./templates/*" | |
schedule: | |
- cron: "0 0 */7 * *" | |
workflow_dispatch: | |
jobs: | |
init: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- name: List changed templates | |
id: all-changed-templates-list | |
uses: tj-actions/changed-files@v45 | |
with: | |
files: templates/** | |
if: ${{github.event_name}} == 'pull_request' | |
- name: List all templates | |
id: all-templates-list | |
run: | | |
sudo apt-get install -y jq | |
echo ALL_FILES="$(printf '%s' "$(ls templates/*)" | jq -Rsc 'split("\n")')" | tee -a $GITHUB_ENV | |
echo ALL_CHANGED_FILES=$(echo -n "${{ steps.all-changed-templates-list.outputs.all_changed_files }}" | jq -Rsc 'split(" ")') | tee -a $GITHUB_ENV | |
- name: Check templates list | |
id: check-templates-list | |
run: | | |
echo ALL_FILES=$ALL_FILES | |
echo ALL_CHANGED_FILES=$ALL_CHANGED_FILES | |
if [ $ALL_CHANGED_FILES = '[]' ]; then echo TEMPLATES_LIST="$ALL_CHANGED_FILES" | tee -a $GITHUB_OUTPUT; else echo TEMPLATES_LIST="$ALL_FILES" | tee -a $GITHUB_OUTPUT; fi | |
outputs: | |
templates_list: ${{steps.check-templates-list.outputs.TEMPLATES_LIST}} | |
image-build: | |
needs: init | |
strategy: | |
fail-fast: false | |
matrix: | |
templates: ${{ fromJson(needs.init.outputs.templates_list) }} | |
uses: ./.github/workflows/builder.yml | |
with: | |
config_path: ${{matrix.templates}} | |
branch_name: ${{github.event.pull_request.base.ref}} | |
is_merged: ${{github.event.pull_request.merged || github.event_name == 'schedule'}} | |
secrets: inherit |