Scheduled Jobs #2727
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: Scheduled Jobs | |
| on: | |
| schedule: | |
| - cron: "0 */8 * * *" | |
| push: | |
| branches: | |
| - main | |
| paths-ignore: | |
| - schema/** | |
| - definitions/** | |
| - docs/COMPARISON.md | |
| - registry.yaml | |
| workflow_dispatch: | |
| inputs: | |
| reset-registry: | |
| description: Space-separated source keys to remove from registry.yaml | |
| default: "" | |
| type: string | |
| reset-paths: | |
| description: Space-separated directories to remove from schema and definitions | |
| default: "" | |
| type: string | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| update-schemas: | |
| name: Update schemas | |
| runs-on: ubuntu-latest | |
| if: github.repository == 'CustomResourceDefinition/catalog' || github.event_name == 'workflow_dispatch' | |
| permissions: | |
| contents: write | |
| outputs: | |
| updated: ${{ steps.committer.outputs.pushed }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| ssh-key: ${{ secrets.DEPLOY_KEY_SCHEDULED_JOBS }} | |
| - uses: actions/setup-go@v6 | |
| with: | |
| go-version-file: go.mod | |
| - name: Optionally reset source registry | |
| if: github.event_name == 'workflow_dispatch' && github.event.inputs.reset-registry != '' | |
| run: | | |
| for key in ${{ github.event.inputs.reset-registry }}; do | |
| yq "del(.sources[\"$key\"])" registry.yaml -i || true | |
| done | |
| - name: Optionally remove paths | |
| if: github.event_name == 'workflow_dispatch' && github.event.inputs.reset-paths != '' | |
| run: | | |
| cd schema | |
| rm -rf ${{ github.event.inputs.reset-paths }} || true | |
| cd - | |
| cd definitions | |
| rm -rf ${{ github.event.inputs.reset-paths }} || true | |
| cd - | |
| - name: Create token | |
| id: app-token | |
| uses: actions/create-github-app-token@v3 | |
| with: | |
| app-id: ${{ vars.AUTOMATION_APP_ID }} | |
| private-key: ${{ secrets.AUTOMATION_APP_PRIVATE_KEY }} | |
| owner: ${{ github.repository_owner }} | |
| repositories: catalog | |
| - run: make update | |
| env: | |
| GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} | |
| - name: Save performance log | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: performance.log | |
| path: build/ephemeral/performance.log | |
| retention-days: 14 | |
| - uses: actions/checkout@v6 | |
| with: | |
| repository: datreeio/CRDs-catalog | |
| path: build/remote/datreeio | |
| - run: make comparison | |
| - uses: EndBug/add-and-commit@v10 | |
| name: Publish changes | |
| if: github.repository == 'CustomResourceDefinition/catalog' && github.ref == 'refs/heads/main' | |
| id: committer | |
| with: | |
| add: | | |
| - schema | |
| - definitions | |
| - docs/COMPARISON.md | |
| - registry.yaml | |
| default_author: github_actions | |
| report-failures: | |
| name: Report failures | |
| runs-on: ubuntu-latest | |
| needs: | |
| - update-schemas | |
| - sync-tags | |
| if: failure() && github.repository == 'CustomResourceDefinition/catalog' && github.ref == 'refs/heads/main' && github.event_name != 'workflow_dispatch' | |
| permissions: | |
| contents: read | |
| issues: write | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Report build failure | |
| uses: CodeReaper/create-issue-action@v1 | |
| with: | |
| title: ${{ github.workflow }} failed | |
| assignees: CodeReaper | |
| body: See the [log](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) for more details. | |
| comment: Latest failed runs [log](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}). | |
| sync-tags: | |
| name: Synchronize tags with kubernetes | |
| runs-on: ubuntu-latest | |
| needs: update-schemas | |
| if: github.repository == 'CustomResourceDefinition/catalog' && github.ref == 'refs/heads/main' && needs.update-schemas.outputs.updated == 'true' | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| ssh-key: ${{ secrets.DEPLOY_KEY_SCHEDULED_JOBS }} | |
| fetch-depth: 0 | |
| - uses: actions/checkout@v6 | |
| with: | |
| repository: kubernetes/kubernetes | |
| path: build/remote/kubernetes | |
| fetch-depth: 0 | |
| - run: make tags | |
| - run: git push --tags |