From 987f64b13122aa007c3e6e753afe6319793f0ce2 Mon Sep 17 00:00:00 2001 From: Jan Snasel Date: Tue, 23 Jan 2024 16:06:44 +0100 Subject: [PATCH] Integrate Drift Manager (#30) * feat: Re-bake * chore: Disable nautobot-app tag workflow * fix: Doc * fix: Enable rebake workflow --- .github/workflows/tag-nautobot-app.yml | 40 ++++++ docs/admin/compatibility_matrix.md | 2 +- docs/user/quick-start.md | 2 +- .../.github/workflows/rebake.yml | 1 - .../.github/workflows/rebake.yml | 1 - .../.github/workflows/rebake.yml | 118 ------------------ 6 files changed, 42 insertions(+), 122 deletions(-) create mode 100644 .github/workflows/tag-nautobot-app.yml delete mode 120000 nautobot-app-chatops/{{ cookiecutter.project_slug }}/.github/workflows/rebake.yml delete mode 120000 nautobot-app-ssot/{{ cookiecutter.project_slug }}/.github/workflows/rebake.yml delete mode 100644 nautobot-app/{{ cookiecutter.project_slug }}/.github/workflows/rebake.yml diff --git a/.github/workflows/tag-nautobot-app.yml b/.github/workflows/tag-nautobot-app.yml new file mode 100644 index 0000000..b542603 --- /dev/null +++ b/.github/workflows/tag-nautobot-app.yml @@ -0,0 +1,40 @@ +--- +name: "Rebake Tag" +on: # yamllint disable-line rule:truthy + push: + tags: + - "nautobot-app-v*" +jobs: + rebake: + container: "ghcr.io/nautobot/cookiecutter-nautobot-app-drift-manager/prod:latest" + runs-on: "ubuntu-22.04" + env: + GITHUB_TOKEN: "${{ secrets.GH_NAUTOBOT_BOT_TOKEN }}" + strategy: + fail-fast: false + max-parallel: 5 # Limit of concurrent jobs + matrix: + name: + - "capacity-metrics" + - "chatops" + - "circuit-maintenance" + - "data-validation-engine" + - "device-lifecycle-mgmt" + - "device-onboarding" + - "firewall-models" + - "floor-plan" + - "golden-config" + - "netbox-importer" + - "nornir" + - "secrets-providers" + - "ssot" + - "version-control" + - "welcome-wizard" + steps: + - name: "Re-bake" + run: | + python -m ntc_cookie_drift_manager \ + rebake \ + --push \ + --template-ref="${{ github.ref }}" \ + https://github.com/nautobot/nautobot-app-${{ matrix.name }}.git diff --git a/docs/admin/compatibility_matrix.md b/docs/admin/compatibility_matrix.md index f419353..4aaf8d7 100644 --- a/docs/admin/compatibility_matrix.md +++ b/docs/admin/compatibility_matrix.md @@ -1,6 +1,6 @@ # Compatibility Matrix -This table shows the target Nautobot versions which the templates in this repository are compatible with. For example, if you wish to build an App for Nautobot 1.6, then you should use the templates from `v1.2` (or whichever is the latest v1.x) of the repository. These specific versions are git tags. +This table shows the target Nautobot versions which the templates in this repository are compatible with. For example, if you wish to build an App for Nautobot 1.6, then you should use the templates from `nautobot-app-v1.2.0` (or whichever is the latest `nautobot-app-v1.x.y) of the repository. These specific versions are git tags. | Repo Release Version | Nautobot First Support Version | Nautobot Last Support Version | | ------------- | -------------------- | ------------- | diff --git a/docs/user/quick-start.md b/docs/user/quick-start.md index 5cdbade..f7aa80b 100644 --- a/docs/user/quick-start.md +++ b/docs/user/quick-start.md @@ -178,5 +178,5 @@ The file `creds.env` will be ignored by git and can be used to override default The cookiecutter CLI tool uses the default branch when using the above example command, to use a different branch, commit, or tag the `--checkout` command line argument can be used. - `--checkout=main` will bake the cookie against the main branch -- `--checkout=v1.0.0` will bake the cookie against the `v1.0.0` tag +- `--checkout=nautobot-app-v1.0.0` will bake the cookie against the `nautobot-app-v1.0.0` tag - `--checkout=6769dee` will bake the cookie against the `6769dee` commit diff --git a/nautobot-app-chatops/{{ cookiecutter.project_slug }}/.github/workflows/rebake.yml b/nautobot-app-chatops/{{ cookiecutter.project_slug }}/.github/workflows/rebake.yml deleted file mode 120000 index 2559c89..0000000 --- a/nautobot-app-chatops/{{ cookiecutter.project_slug }}/.github/workflows/rebake.yml +++ /dev/null @@ -1 +0,0 @@ -../../../../nautobot-app/{{ cookiecutter.project_slug }}/.github/workflows/rebake.yml \ No newline at end of file diff --git a/nautobot-app-ssot/{{ cookiecutter.project_slug }}/.github/workflows/rebake.yml b/nautobot-app-ssot/{{ cookiecutter.project_slug }}/.github/workflows/rebake.yml deleted file mode 120000 index 2559c89..0000000 --- a/nautobot-app-ssot/{{ cookiecutter.project_slug }}/.github/workflows/rebake.yml +++ /dev/null @@ -1 +0,0 @@ -../../../../nautobot-app/{{ cookiecutter.project_slug }}/.github/workflows/rebake.yml \ No newline at end of file diff --git a/nautobot-app/{{ cookiecutter.project_slug }}/.github/workflows/rebake.yml b/nautobot-app/{{ cookiecutter.project_slug }}/.github/workflows/rebake.yml deleted file mode 100644 index 04282da..0000000 --- a/nautobot-app/{{ cookiecutter.project_slug }}/.github/workflows/rebake.yml +++ /dev/null @@ -1,118 +0,0 @@ ---- -name: "Rebake Cookie" -on: # yamllint disable-line rule:truthy - workflow_call: - inputs: - cookie: - description: "The cookie to rebake" - type: "string" - default: "" - draft: - description: "Whether to create the pull request as a draft" - type: "string" - default: "" - pull-request: - description: "The pull request strategy" - type: "string" - default: "" - template: - description: "The template repository URL" - type: "string" - default: "" - template-dir: - description: "The directory within the template repository to use as the template" - type: "string" - default: "" - template-ref: - description: "The branch or tag to use for the template" - type: "string" - default: "" - drift-manager-tag: - description: "The drift manager Docker image tag to use" - type: "string" - default: "latest" - workflow_dispatch: - inputs: - cookie: - description: "The cookie to rebake" - type: "string" - default: "" - draft: - description: "Whether to create the pull request as a draft" - type: "string" - default: "" - pull-request: - description: "The pull request strategy" - type: "string" - default: "" - template: - description: "The template repository URL" - type: "string" - default: "" - template-dir: - description: "The directory within the template repository to use as the template" - type: "string" - default: "" - template-ref: - description: "The branch or tag to use for the template" - type: "string" - default: "" - drift-manager-tag: - description: "The drift manager Docker image tag to use" - type: "string" - default: "latest" -jobs: - rebake: - runs-on: "ubuntu-22.04" - permissions: - actions: "write" - contents: "write" - packages: "read" - pull-requests: "write" - container: "ghcr.io/nautobot/cookiecutter-nautobot-app-drift-manager/prod:{% raw %}${{ github.event.inputs.drift-manager-tag }}{% endraw %}" - env: - GITHUB_TOKEN: "{% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %}" - steps: - - name: "Configure Rebake Arguments" - id: "config" - shell: "bash" - run: | - ARGS='--push' - - if [[ '{% raw %}${{ github.event.inputs.draft }}{% endraw %}' == 'true' ]]; then - ARGS="$ARGS --draft" - elif [[ '{% raw %}${{ github.event.inputs.draft }}{% endraw %}' == 'false' ]]; then - ARGS="$ARGS --no-draft" - elif [[ '{% raw %}${{ github.event.inputs.draft }}{% endraw %}' == '' ]]; then - echo "Using repo default value for --draft" - else - echo "ERROR: Invalid value for draft: '{% raw %}${{ github.event.inputs.draft }}{% endraw %}'" - exit 1 - fi - - if [[ '{% raw %}${{ github.event.inputs.pull-request }}{% endraw %}' != '' ]]; then - ARGS="$ARGS --pull-request='{% raw %}${{ github.event.inputs.pull-request }}{% endraw %}'" - fi - - if [[ '{% raw %}${{ github.event.inputs.template }}{% endraw %}' != '' ]]; then - ARGS="$ARGS --template='{% raw %}${{ github.event.inputs.template }}{% endraw %}'" - fi - - if [[ '{% raw %}${{ github.event.inputs.template-dir }}{% endraw %}' != '' ]]; then - ARGS="$ARGS --template-dir='{% raw %}${{ github.event.inputs.template-dir }}{% endraw %}'" - fi - - if [[ '{% raw %}${{ github.event.inputs.template-ref }}{% endraw %}' != '' ]]; then - ARGS="$ARGS --template-ref='{% raw %}${{ github.event.inputs.template-ref }}{% endraw %}'" - fi - - if [[ '{% raw %}${{ github.event.inputs.cookie }}{% endraw %}' == '' ]]; then - ARGS="$ARGS '{% raw %}${{ github.repositoryUrl }}{% endraw %}'" - else - ARGS="$ARGS '{% raw %}${{ github.event.inputs.cookie }}{% endraw %}'" - fi - - echo "args=$ARGS" >> $GITHUB_OUTPUT - - name: "Rebake" - run: | - python -m ntc_cookie_drift_manager rebake {% raw %}${{ steps.config.outputs.args }}{% endraw %}