From a62daf95c41d44f2450b3b5ca7c6efbad93b358b Mon Sep 17 00:00:00 2001 From: geokrety-bot Date: Sat, 5 Aug 2023 11:36:35 +0200 Subject: [PATCH] ci: Initial docker automated build --- .github/workflows/docker-build.yml | 58 +++++++++++ .github/workflows/pre-commit.yml | 18 ++++ .github/workflows/semantic-release.yml | 45 +++++++++ .gitignore | 1 + .pre-commit-config.yaml | 23 +++++ .releaserc.json | 130 +++++++++++++++++++++++++ 6 files changed, 275 insertions(+) create mode 100644 .github/workflows/docker-build.yml create mode 100644 .github/workflows/pre-commit.yml create mode 100644 .github/workflows/semantic-release.yml create mode 100644 .pre-commit-config.yaml create mode 100644 .releaserc.json diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml new file mode 100644 index 0000000..74b521d --- /dev/null +++ b/.github/workflows/docker-build.yml @@ -0,0 +1,58 @@ +name: docker-build + +on: + schedule: + - cron: "0 10 * * *" + push: + branches: + - "**" + tags: + - "v*.*.*" + pull_request: + branches: + - "main" + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + # list of Docker images to use as base name for tags + images: | + geokrety/bootstrap-email + # generate Docker tags based on the following events/attributes + tags: | + type=schedule + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=sha + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to Docker Hub + if: github.event_name != 'pull_request' + uses: docker/login-action@v2 + with: + username: ${{ vars.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push - base + uses: docker/build-push-action@v4 + with: + file: Dockerfile + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 0000000..0bf7dbd --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,18 @@ +name: pre-commit + +on: + pull_request: + push: + branches: + - '*' + +jobs: + + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-python@v4 + + - uses: pre-commit/action@v3.0.0 diff --git a/.github/workflows/semantic-release.yml b/.github/workflows/semantic-release.yml new file mode 100644 index 0000000..f06c7a0 --- /dev/null +++ b/.github/workflows/semantic-release.yml @@ -0,0 +1,45 @@ +name: Semantic release + +on: + push: + branches: + - main + +jobs: + release: + if: "!contains(github.event.head_commit.message, 'skip ci')" + runs-on: ubuntu-latest + permissions: + contents: write # to be able to publish a GitHub release + issues: write # to be able to comment on released issues + pull-requests: write # to be able to comment on released pull requests + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + token: ${{ secrets.GH_TOKEN }} + + # setting up Node + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: "lts/*" + + # disable package-lock.json to stop it being created + - name: Disable package-lock.json + run: npm config set package-lock false + + # Installing package dependencies + - name: Install dependencies + run: | + npm i -D js-yaml@4.1.0 conventional-changelog-conventionalcommits semantic-release @semantic-release/commit-analyzer @semantic-release/release-notes-generator @semantic-release/exec @semantic-release/changelog @semantic-release/github + + - name: New tag + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GIT_AUTHOR_NAME: geokrety-bot + GIT_AUTHOR_EMAIL: geokrety-bot@users.noreply.github.com + GIT_COMMITTER_NAME: geokrety-bot + GIT_COMMITTER_EMAIL: geokrety-bot@users.noreply.github.com + run: npx semantic-release diff --git a/.gitignore b/.gitignore index 9a39be9..5f6b446 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ docker-compose.yml src/.ruby/ +src/.sass-cache/ \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..7b92567 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,23 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +exclude: | + (?x)( + ^vendor/ + ) + +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.2.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files + - id: check-json + - id: pretty-format-json + args: ["--autofix"] + + - repo: https://github.com/Lucas-C/pre-commit-hooks + rev: v1.1.9 + hooks: + - id: remove-crlf diff --git a/.releaserc.json b/.releaserc.json new file mode 100644 index 0000000..1fbaffe --- /dev/null +++ b/.releaserc.json @@ -0,0 +1,130 @@ +{ + "branches": [ + "main" + ], + "debug": "true", + "plugins": [ + [ + "@semantic-release/commit-analyzer", + { + "parserOpts": { + "noteKeywords": [ + "BREAKING CHANGE", + "BREAKING CHANGES" + ] + }, + "preset": "angular", + "releaseRules": [ + { + "breaking": true, + "release": "major" + }, + { + "release": "minor", + "type": "feat" + }, + { + "release": "patch", + "type": "fix" + }, + { + "release": false, + "type": "docs" + }, + { + "release": "patch", + "type": "style" + }, + { + "release": "patch", + "type": "refactor" + }, + { + "release": "patch", + "type": "perf" + }, + { + "release": false, + "type": "test" + }, + { + "release": "patch", + "type": "chore" + }, + { + "release": "patch", + "type": "dependencies" + }, + { + "release": "patch", + "type": "revert" + }, + { + "release": "patch", + "type": "translation" + }, + { + "release": "patch", + "type": "ci" + } + ] + } + ], + [ + "@semantic-release/release-notes-generator", + { + "parserOpts": { + "noteKeywords": [ + "BREAKING CHANGE", + "BREAKING CHANGES" + ] + }, + "preset": "conventionalCommits", + "presetConfig": { + "types": [ + { + "section": "Features", + "type": "feat" + }, + { + "section": "Bug Fixes", + "type": "fix" + }, + { + "section": "Performance Improvements", + "type": "perf" + }, + { + "section": "Reverts", + "type": "revert" + }, + { + "section": "Translations", + "type": "translation" + }, + { + "section": "Code Refactoring", + "type": "refactor" + }, + { + "section": "Style", + "type": "style" + }, + { + "hidden": false, + "section": "Dependencies", + "type": "dependencies" + }, + { + "hidden": false, + "section": "Chores", + "type": "chore" + } + ] + } + } + ], + "@semantic-release/changelog", + "@semantic-release/github" + ] +}