|
| 1 | +name: Validation |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request_target: |
| 5 | + push: |
| 6 | + branches: [main] |
| 7 | + paths: |
| 8 | + - "domains/*" |
| 9 | + - "tests/*" |
| 10 | + - "utils/*" |
| 11 | + - ".github/workflows/validation.yml" |
| 12 | + - "dnsconfig.js" |
| 13 | + workflow_dispatch: |
| 14 | + |
| 15 | +concurrency: |
| 16 | + group: ${{ github.ref }}-validation |
| 17 | + cancel-in-progress: true |
| 18 | + |
| 19 | +jobs: |
| 20 | + dns: |
| 21 | + name: DNS |
| 22 | + runs-on: ubuntu-latest |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@v4 |
| 25 | + with: |
| 26 | + ref: ${{ github.event.pull_request.head.sha }} |
| 27 | + |
| 28 | + - id: create_token |
| 29 | + uses: tibdex/github-app-token@v2 |
| 30 | + with: |
| 31 | + app_id: ${{ secrets.APP_ID }} |
| 32 | + private_key: ${{ secrets.PRIVATE_KEY }} |
| 33 | + |
| 34 | + - name: Check DNS |
| 35 | + id: dns_check |
| 36 | + uses: is-a-dev/dnscontrol-action@main |
| 37 | + with: |
| 38 | + args: check |
| 39 | + config_file: "dnsconfig.js" |
| 40 | + |
| 41 | + - name: Add Validated DNS Label |
| 42 | + if: ${{ github.event_name == 'pull_request' && steps.dns_check.outcome == 'success' }} |
| 43 | + uses: actions-ecosystem/action-add-labels@v1 |
| 44 | + with: |
| 45 | + labels: "Validated DNS" |
| 46 | + github_token: ${{ steps.create_token.outputs.token }} |
| 47 | + issue_number: ${{ github.event.pull_request.number }} |
| 48 | + |
| 49 | + - name: Remove Invalid DNS Label |
| 50 | + if: ${{ github.event_name == 'pull_request' && steps.dns_check.outcome == 'success' }} |
| 51 | + uses: actions-ecosystem/action-remove-labels@v1 |
| 52 | + with: |
| 53 | + labels: "Invalid DNS" |
| 54 | + github_token: ${{ steps.create_token.outputs.token }} |
| 55 | + issue_number: ${{ github.event.pull_request.number }} |
| 56 | + |
| 57 | + - name: Add Invalid DNS Label |
| 58 | + if: ${{ github.event_name == 'pull_request' && failure() }} |
| 59 | + uses: actions-ecosystem/action-add-labels@v1 |
| 60 | + with: |
| 61 | + labels: "Invalid DNS" |
| 62 | + github_token: ${{ steps.create_token.outputs.token }} |
| 63 | + issue_number: ${{ github.event.pull_request.number }} |
| 64 | + |
| 65 | + - name: Remove Validated DNS Label |
| 66 | + if: ${{ github.event_name == 'pull_request' && failure() }} |
| 67 | + uses: actions-ecosystem/action-remove-labels@v1 |
| 68 | + with: |
| 69 | + labels: "Validated DNS" |
| 70 | + github_token: ${{ steps.create_token.outputs.token }} |
| 71 | + issue_number: ${{ github.event.pull_request.number }} |
| 72 | + |
| 73 | + json: |
| 74 | + name: JSON |
| 75 | + runs-on: ubuntu-latest |
| 76 | + steps: |
| 77 | + - uses: actions/checkout@v4 |
| 78 | + with: |
| 79 | + ref: ${{ github.event.pull_request.head.sha }} |
| 80 | + |
| 81 | + - id: create_token |
| 82 | + uses: tibdex/github-app-token@v2 |
| 83 | + with: |
| 84 | + app_id: ${{ secrets.APP_ID }} |
| 85 | + private_key: ${{ secrets.PRIVATE_KEY }} |
| 86 | + |
| 87 | + - name: JSON Syntax Check |
| 88 | + id: json_check |
| 89 | + uses: limitusus/json-syntax-check@v2 |
| 90 | + with: |
| 91 | + pattern: "\\.json$" |
| 92 | + env: |
| 93 | + BASE: "domains/" |
| 94 | + |
| 95 | + - name: Add Validated JSON Label |
| 96 | + if: ${{ github.event_name == 'pull_request' && steps.json_check.outcome == 'success' }} |
| 97 | + uses: actions-ecosystem/action-add-labels@v1 |
| 98 | + with: |
| 99 | + labels: "Validated JSON" |
| 100 | + github_token: ${{ steps.create_token.outputs.token }} |
| 101 | + issue_number: ${{ github.event.pull_request.number }} |
| 102 | + |
| 103 | + - name: Remove Invalid JSON Label |
| 104 | + if: ${{ github.event_name == 'pull_request' && steps.json_check.outcome == 'success' }} |
| 105 | + uses: actions-ecosystem/action-remove-labels@v1 |
| 106 | + with: |
| 107 | + labels: "Invalid JSON" |
| 108 | + github_token: ${{ steps.create_token.outputs.token }} |
| 109 | + issue_number: ${{ github.event.pull_request.number }} |
| 110 | + |
| 111 | + - name: Add Invalid JSON Label |
| 112 | + if: ${{ github.event_name == 'pull_request' && failure() }} |
| 113 | + uses: actions-ecosystem/action-add-labels@v1 |
| 114 | + with: |
| 115 | + labels: "Invalid JSON" |
| 116 | + github_token: ${{ steps.create_token.outputs.token }} |
| 117 | + issue_number: ${{ github.event.pull_request.number }} |
| 118 | + |
| 119 | + - name: Remove Validated JSON Label |
| 120 | + if: ${{ github.event_name == 'pull_request' && failure() }} |
| 121 | + uses: actions-ecosystem/action-remove-labels@v1 |
| 122 | + with: |
| 123 | + labels: "Validated JSON" |
| 124 | + github_token: ${{ steps.create_token.outputs.token }} |
| 125 | + issue_number: ${{ github.event.pull_request.number }} |
| 126 | + |
| 127 | + tests: |
| 128 | + name: Tests |
| 129 | + if: "!contains(github.event.head_commit.message, '[skip-ci]')" |
| 130 | + runs-on: ubuntu-latest |
| 131 | + steps: |
| 132 | + - uses: actions/checkout@v4 |
| 133 | + |
| 134 | + - run: npm install |
| 135 | + |
| 136 | + - run: npm test |
0 commit comments