From 79487e884d1fb7ca85566f69c8b9af04e9603bc6 Mon Sep 17 00:00:00 2001 From: "S. Amir Mohammad Najafi" Date: Wed, 8 Nov 2023 17:02:19 +0330 Subject: [PATCH] feat: add base workspace files --- .editorconfig | 15 ++++ .github/CODEOWNERS | 1 + .github/dependabot.yml | 35 ++++++++ .github/labels.yml | 90 +++++++++++++++++++ .github/pull_request_template.md | 3 + .github/workflows/publish-container.yml | 111 ++++++++++++++++++++++++ .github/workflows/sync-labels.yml | 30 +++++++ .gitignore | 37 ++++++++ .prettierrc.json | 4 + .vscode/extensions.json | 10 +++ .vscode/settings.json | 17 ++++ LICENSE | 21 +++++ README.md | 1 + 13 files changed, 375 insertions(+) create mode 100644 .editorconfig create mode 100644 .github/CODEOWNERS create mode 100644 .github/dependabot.yml create mode 100644 .github/labels.yml create mode 100644 .github/pull_request_template.md create mode 100644 .github/workflows/publish-container.yml create mode 100644 .github/workflows/sync-labels.yml create mode 100644 .gitignore create mode 100644 .prettierrc.json create mode 100644 .vscode/extensions.json create mode 100644 .vscode/settings.json create mode 100644 LICENSE create mode 100644 README.md diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..485f80b --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +# EditorConfig is awesome: https://EditorConfig.org + +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true +max_line_length = 120 + +[*.md] +trim_trailing_whitespace = false diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..bb170df --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @AliMD diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..034e0d9 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,35 @@ +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + open-pull-requests-limit: 20 + reviewers: + - AliMD + schedule: + interval: daily + labels: + - ci + - priority-low + - maintenance + groups: + github-actions: + patterns: + - '*' + + - package-ecosystem: docker + directory: /**/Dockerfile + open-pull-requests-limit: 20 + reviewers: + - AliMD + schedule: + interval: daily + labels: + - ci + - priority-low + - maintenance + # groups: + # github-actions: + # patterns: + # - '*' diff --git a/.github/labels.yml b/.github/labels.yml new file mode 100644 index 0000000..ec05331 --- /dev/null +++ b/.github/labels.yml @@ -0,0 +1,90 @@ +- name: 'bug-report' + color: ee0811 + description: 'Inconsistencies or issues which will cause a problem for users or implementors.' +- name: 'feature-request' + color: 0e9a26 + description: 'Request new features or options.' + +- name: 'breaking-change' + color: ee0701 + description: 'A change that changes the API or breaks backward compatibility for users.' +- name: 'bugfix' + color: ee0701 + description: 'Inconsistencies or issues which will cause a problem for users or implementors.' +- name: 'documentation' + color: 0052cc + description: 'Solely about the documentation of the project.' +- name: 'enhancement' + color: 1d76db + description: 'Enhancement of the code, not introducing new features.' +- name: 'refactor' + color: 1d76db + description: 'Updating the code with simpler, easier to understand or more efficient syntax or methods.' +- name: 'performance' + color: 1d76db + description: 'Improving performance of the project, not introducing new features.' +- name: 'new-feature' + color: 0e8a16 + description: 'New features or options.' +- name: 'maintenance' + color: 2af79e + description: 'Generic maintenance tasks.' +- name: 'ci' + color: 1d76db + description: 'Work that improves the continuous integration.' +- name: 'dependencies' + color: 1d76db + description: 'Change in project dependencies.' + +- name: 'in-progress' + color: fbca04 + description: 'Issue is currently being worked on by a developer.' +- name: 'stale' + color: fef2c0 + description: 'No activity for quite some time.' +- name: 'no-stale' + color: fef2c0 + description: 'This is exempt from the stale bot.' +- name: 'auto-closed' + color: fef2c0 + description: 'No activity for quite some time.' + +- name: 'security' + color: ee0701 + description: 'Addressing a vulnerability or security risk in this project.' +- name: 'incomplete' + color: fef2c0 + description: 'Missing information.' +- name: 'invalid' + color: fef2c0 + description: "This is off-topic, spam, or otherwise doesn't apply to this project." + +- name: 'good first issue' + color: 0e8a16 + description: 'Good first issue for people wanting to contribute to this project.' +- name: 'help-wanted' + color: 0e8a16 + description: 'We need some extra helping hands or expertise in order to resolve this!' + +- name: 'priority-critical' + color: ee0701 + description: 'Must be addressed as soon as possible.' +- name: 'priority-high' + color: b60205 + description: 'After critical issues are fixed, these should be dealt with before any further issues.' +- name: 'priority-medium' + color: 0e8a16 + description: 'This issue may be useful, and needs some attention.' +- name: 'priority-low' + color: e4ea8a + description: 'Nice addition, maybe... someday...' + +- name: 'major' + color: b60205 + description: 'This PR causes a major bump in the version number.' +- name: 'minor' + color: 0e8a16 + description: 'This PR causes a minor bump in the version number.' +- name: 'release' + color: 5319E7 + description: 'Release PR from next to main.' diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..ab55d8b --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,3 @@ +## Description + + diff --git a/.github/workflows/publish-container.yml b/.github/workflows/publish-container.yml new file mode 100644 index 0000000..73d457c --- /dev/null +++ b/.github/workflows/publish-container.yml @@ -0,0 +1,111 @@ +# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json + +name: Build & Publish Containers + +on: + workflow_dispatch: + + push: + branches: + - main + + pull_request: + +env: + REGISTRY: ghcr.io + USER: alwatr + +jobs: + build: + if: github.repository_owner == 'Alwatr' + + name: Build & Publish Containers + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + include: + - name: nginx + path: nginx + + - name: nginx-pwa + path: nginx-pwa + + - name: nginx-ws + path: nginx-ws + + permissions: + contents: read + packages: write + id-token: write + + steps: + - name: โคต๏ธ Checkout repository + uses: actions/checkout@v4.0.0 + + - name: โ” Check Container files changed + id: file_change + uses: dorny/paths-filter@v2.11.1 + with: + filters: | + container_folder: + ./${{ matrix.path }}/* + + - name: ๐Ÿ— Extract version from dockerfile + if: ${{ steps.file_change.outputs.container_folder == 'true' }} + id: version + run: | + version_full=$(grep 'cloud.alwatr.image.version.full' ./${{ matrix.path }}/Dockerfile | cut -d'"' -f2) + version_short=$(grep 'cloud.alwatr.image.version.short' ./${{ matrix.path }}/Dockerfile | cut -d'"' -f2) + echo "version_full=$version_full" >> $GITHUB_OUTPUT + echo "version_short=$version_short" >> $GITHUB_OUTPUT + echo "version_full: $version_full" + echo "version_short: $version_short" + + - name: ๐Ÿ— Install cosign + if: ${{ github.event_name != 'pull_request' && steps.file_change.outputs.container_folder == 'true' }} + uses: sigstore/cosign-installer@v3.1.2 + + - name: ๐Ÿ— Setup Docker Buildx + if: ${{ steps.file_change.outputs.container_folder == 'true' }} + uses: docker/setup-buildx-action@v3.0.0 + + - name: ๐Ÿ— Cache Docker Layers + if: ${{ steps.file_change.outputs.container_folder == 'true' }} + uses: actions/cache@v3 + with: + path: /tmp/.buildx-cache + key: container-${{ matrix.name }} + + - name: ๐Ÿ— Log into registry ${{env.REGISTRY}} + if: ${{ github.event_name != 'pull_request' && steps.file_change.outputs.container_folder == 'true' }} + uses: docker/login-action@v3.0.0 + with: + registry: ${{env.REGISTRY}} + username: ${{github.repository_owner}} + password: ${{secrets.GITHUB_TOKEN}} + + - name: ๐Ÿš€ Build and push container image + if: ${{ steps.file_change.outputs.container_folder == 'true' }} + id: build_and_push + uses: docker/build-push-action@v5.0.0 + with: + context: ./${{matrix.path}} + push: ${{github.event_name != 'pull_request'}} + tags: | + ${{env.REGISTRY}}/${{env.USER}}/${{matrix.name}}:${{steps.version.outputs.version_full}} + ${{env.REGISTRY}}/${{env.USER}}/${{matrix.name}}:${{steps.version.outputs.version_short}} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + build-args: | + BUILD_DATE=${{github.event.repository.updated_at}} + BUILD_REV=${{github.sha}} + + - name: ๐Ÿ— Sign the image with GitHub OIDC Token + if: ${{ github.event_name != 'pull_request' && steps.file_change.outputs.container_folder == 'true' }} + env: + COSIGN_EXPERIMENTAL: 'true' + run: | + cosign sign --yes "${{env.REGISTRY}}/${{env.USER}}/${{matrix.name}}:${{steps.version.outputs.version_full}}@${{steps.build_and_push.outputs.digest}}" + cosign sign --yes "${{env.REGISTRY}}/${{env.USER}}/${{matrix.name}}:${{steps.version.outputs.version_short}}@${{steps.build_and_push.outputs.digest}}" diff --git a/.github/workflows/sync-labels.yml b/.github/workflows/sync-labels.yml new file mode 100644 index 0000000..62aa78b --- /dev/null +++ b/.github/workflows/sync-labels.yml @@ -0,0 +1,30 @@ +# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json + +name: Sync labels + +on: + workflow_dispatch: + push: + branches: + - main + - next + paths: + - .github/labels.yml + +jobs: + labels: + name: Sync labels + runs-on: ubuntu-latest + + permissions: + contents: read + issues: write + + steps: + - name: โคต๏ธ Check out code from GitHub + uses: actions/checkout@v4.1.0 + + - name: ๐Ÿš€ Run Label Syncer + uses: micnncim/action-label-syncer@v1.3.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..696f10c --- /dev/null +++ b/.gitignore @@ -0,0 +1,37 @@ +# Specifies intentionally untracked files to ignore when using Git +# http://git-scm.com/docs/gitignore + +# OSX +.DS_STORE +.DS_Store +._* + +# Windows +Thumbs.db +Desktop.ini + +# Logs +*.log* + +# Build +dist +build +.tsbuildinfo +*.map +*.d.ts +*.js +!*.config.js +!**/res/*.js + +# Dependencies +node_modules +package-lock.json + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..a0f24c9 --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,4 @@ +{ + "singleQuote": true, + "bracketSpacing": false +} diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..4e098c4 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,10 @@ +{ + "recommendations": [ + "davidanson.vscode-markdownlint", + "editorconfig.editorconfig", + "esbenp.prettier-vscode", + "jgclark.vscode-todo-highlight", + "streetsidesoftware.code-spell-checker-persian", + "streetsidesoftware.code-spell-checker" + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..bebb7de --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,17 @@ +{ + "editor.wordWrapColumn": 120, + "editor.defaultFormatter": "esbenp.prettier-vscode", + "prettier.useEditorConfig": true, + "files.associations": { + "*.mt": "routeros", + "*.conf.template": "nginx", + "ssh_config": "ssh_config", + "*.njk": "html", + "ssh-config": "ssh_config" + }, + "markdownlint.ignore": ["**/CHANGELOG.md"], + "cSpell.language": "en,fa,fa-IR", + "cSpell.words": ["alwatr"], + "git.autoStash": true, + "githubPullRequests.ignoredPullRequestBranches": ["main", "next"] +} diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..1449437 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 Alwatr + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..d61bfc0 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# Alwatr Nginx