Update Senderz templates: chunked DKIM + SES Easy-DKIM CNAMEs #2439
Workflow file for this run
This file contains hidden or 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: Lint Domain Connect Templates | |
| #version: 2024-05-10 v1 | |
| on: | |
| pull_request_target: | |
| branches: | |
| - master | |
| merge_group: | |
| branches: | |
| - master | |
| jobs: | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Setup refs | |
| id: setup-refs | |
| run: | | |
| echo "base_sha=${{ github.event.pull_request.base.sha }}${{ github.event.merge_group.base_sha }}" >> "$GITHUB_OUTPUT" | |
| echo "head_sha=${{ github.event.pull_request.head.sha }}${{ github.event.merge_group.head_sha }}" >> "$GITHUB_OUTPUT" | |
| - name: Check out code | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 2 | |
| ref: ${{ steps.setup-refs.outputs.head_sha }} | |
| - name: Dump GitHub context | |
| env: | |
| GITHUB_CONTEXT: ${{ toJson(github) }} | |
| run: echo "$GITHUB_CONTEXT" | |
| - name: Get all changed json files | |
| id: changed-json-files | |
| uses: tj-actions/changed-files@v45 | |
| with: | |
| files: '*.json' | |
| - name: Print all changed json files | |
| if: steps.changed-json-files.outputs.any_changed == 'true' | |
| env: | |
| ALL_CHANGED_FILES: ${{ steps.changed-json-files.outputs.all_changed_files }} | |
| run: | | |
| for file in ${ALL_CHANGED_FILES}; do | |
| echo "$file was changed" | |
| done | |
| - name: Check all modified json files for version update | |
| id: check-version-bump-needed | |
| if: steps.changed-json-files.outputs.modified_files_count > 0 | |
| env: | |
| ALL_MODIFIED_FILES: ${{ steps.changed-json-files.outputs.modified_files }} | |
| run: | | |
| echo "version_bump_check<<EOF" >> $GITHUB_ENV | |
| echo "version_bump_check=0" >> "$GITHUB_OUTPUT" | |
| echo "Base: ${{ steps.setup-refs.outputs.base_sha }}" | |
| echo "Head: ${{ steps.setup-refs.outputs.head_sha }}" | |
| for file in ${ALL_MODIFIED_FILES}; do | |
| echo "$file was modified" | |
| echo "File diff $file:" | |
| git diff -U0 ${{ steps.setup-refs.outputs.base_sha }}..${{ steps.setup-refs.outputs.head_sha }} -- $file | |
| echo "Check version field diff:" | |
| if ! git diff -U0 ${{ steps.setup-refs.outputs.base_sha }}..${{ steps.setup-refs.outputs.head_sha }} -- $file | grep "version"; then | |
| echo "No version update detected!" | |
| echo "$file" >> $GITHUB_ENV | |
| echo "version_bump_check=1" >> "$GITHUB_OUTPUT" | |
| fi | |
| done | |
| echo "EOF" >> $GITHUB_ENV | |
| - name: Comment PR with version check result | |
| if: steps.check-version-bump-needed.outputs.version_bump_check == 1 && github.event_name == 'pull_request_target' | |
| uses: thollander/actions-comment-pull-request@v2 | |
| with: | |
| message: | | |
| Version bump needed for the files: | |
| ``` | |
| ${{ env.version_bump_check }} | |
| ``` | |
| comment_tag: version_bump | |
| - name: Remove comment PR with version check result if not needed | |
| if: steps.check-version-bump-needed.outputs.version_bump_check != 1 && github.event_name == 'pull_request_target' | |
| uses: thollander/actions-comment-pull-request@v2 | |
| with: | |
| message: "Version bump not needed" | |
| mode: delete | |
| create_if_not_exists: false | |
| comment_tag: version_bump | |
| - name: Set up Go | |
| uses: actions/setup-go@v2 | |
| with: | |
| go-version: '^1.16' | |
| - name: Install dc-template-linter | |
| run: | | |
| go install github.com/Domain-Connect/dc-template-linter@latest | |
| echo `go env GOPATH`/bin | |
| - name: Install jq | |
| run: sudo apt-get install -y jq | |
| - name: Lint changed Templates | |
| if: steps.changed-json-files.outputs.any_changed == 'true' | |
| id: linter-output | |
| env: | |
| ALL_CHANGED_FILES: ${{ steps.changed-json-files.outputs.all_changed_files }} | |
| run: | | |
| linter_error=0 | |
| { | |
| echo "linter_output<<EOF" | |
| for file in ${ALL_CHANGED_FILES}; do | |
| echo "### \`$file\`" | |
| echo "| Level | Code | Note |" | |
| echo "| ----- | ---- | ---- |" | |
| `go env GOPATH`/bin/dc-template-linter -loglevel info $file 2>&1 | while IFS= read -r line; do | |
| level=$(echo "$line" | jq -r '.level // empty') | |
| code=$(echo "$line" | jq -r '.code // empty') | |
| note=$(echo "$line" | jq -r '.dctl_note // empty') | |
| if [ -n "$level" ] && [ -n "$code" ]; then | |
| echo "| $level | [$code](https://github.com/Domain-Connect/dc-template-linter/wiki/$code) | $note |" | |
| fi | |
| done | |
| echo "" | |
| if ! `go env GOPATH`/bin/dc-template-linter -tolerate warn $file 2>/dev/null; then | |
| linter_error=1 | |
| fi | |
| done | |
| echo "EOF" | |
| } >> $GITHUB_ENV | |
| echo "linter_error=$linter_error" >> "$GITHUB_OUTPUT" | |
| - name: Comment PR with linter error result | |
| if: steps.linter-output.outputs.linter_error == 1 && github.event_name == 'pull_request_target' | |
| uses: thollander/actions-comment-pull-request@v2 | |
| with: | |
| message: | | |
| ## Linter error | |
| ${{ env.linter_output }} | |
| comment_tag: linter | |
| - name: Comment PR with linter OK result | |
| if: steps.linter-output.outputs.linter_error != 1 && github.event_name == 'pull_request_target' | |
| uses: thollander/actions-comment-pull-request@v2 | |
| with: | |
| message: | | |
| ## Linter OK | |
| ${{ env.linter_output }} | |
| comment_tag: linter | |
| - name: Fail job if version check or linter fails | |
| if: steps.linter-output.outputs.linter_error == 1 || steps.check-version-bump-needed.outputs.version_bump_check == 1 | |
| run: exit 1 | |