diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..496b7b1 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,18 @@ +version: 2 +updates: + - package-ecosystem: npm + directory: '/' + schedule: + interval: daily + commit-message: + prefix: fix + prefix-development: chore + include: scope + - package-ecosystem: github-actions + directory: '/' + schedule: + interval: weekly + commit-message: + prefix: fix + prefix-development: chore + include: scope diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml new file mode 100644 index 0000000..1204036 --- /dev/null +++ b/.github/workflows/automerge.yml @@ -0,0 +1,15 @@ +name: 'Auto Merge PRs' + +on: + workflow_call: + +jobs: + automerge: + runs-on: ubuntu-latest + permissions: + pull-requests: write + contents: write + steps: + - uses: fastify/github-action-merge-dependabot@v3 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/builder.yml b/.github/workflows/builder.yml new file mode 100644 index 0000000..3033c7a --- /dev/null +++ b/.github/workflows/builder.yml @@ -0,0 +1,51 @@ +name: 'Setup Docker Image(s)' + +on: + workflow_call: + inputs: + branch: + description: 'The branch for the workflow' + default: 'dev' + required: true + type: string +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +permissions: + contents: read + packages: write + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Check out repository ๐ŸŽ‰ + uses: actions/checkout@v3 + + - name: Set up Docker Buildx ๐Ÿ— + uses: docker/setup-buildx-action@v2 + with: + buildkitd-flags: --debug + + - name: Log in to the Container registry ๐Ÿ” + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker ๐Ÿ™๐Ÿฝ + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image ๐Ÿฆพ + uses: docker/build-push-action@v3.1.1 + with: + context: . + file: Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }},${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ inputs.branch }},${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..76facac --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,54 @@ +name: 'Continuous Integration' + +on: + workflow_call: + +permissions: + checks: write + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.ref }} + cancel-in-progress: true + +jobs: + ci: + runs-on: ubuntu-latest + steps: + - name: Check out repository โœจ (non-dependabot) + if: ${{ github.actor != 'dependabot[bot]' }} + uses: actions/checkout@v3 + + - name: Check out repository ๐ŸŽ‰ (dependabot) + if: ${{ github.actor == 'dependabot[bot]' }} + uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.sha }} + + - name: Setup node env ๐Ÿ“ฆ + uses: actions/setup-node@v3 + with: + node-version: 10 + + - name: Install dependencies ๐Ÿš€ + run: npm i --prefer-offline --no-audit --omit=optional + + - name: Run linter(s) ๐Ÿ’… + uses: wearerequired/lint-action@v2 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + continue_on_error: false + git_name: github-actions[bot] + git_email: github-actions[bot]@users.noreply.github.com + auto_fix: false + prettier: true + prettier_extensions: js,cjs,ts,json + + - name: Run hadolint ๐Ÿณ + uses: hadolint/hadolint-action@v2.1.0 + with: + dockerfile: Dockerfile + ignore: DL3003,DL3008 + + # - name: Run tests ๐Ÿงช + # run: npm run test diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml new file mode 100644 index 0000000..62181a5 --- /dev/null +++ b/.github/workflows/pipeline.yml @@ -0,0 +1,42 @@ +name: 'The Pipeline' + +on: + push: + branches: + - main + - master + pull_request: + branches: + - main + - master + +jobs: + extract-branch: + name: 'Fetch branch' + runs-on: ubuntu-latest + outputs: + current_branch: ${{ steps.get-branch.outputs.current_branch }} + steps: + - name: Extract branch name ๐Ÿ•Š + id: get-branch + run: echo "::set-output name=current_branch::${GITHUB_REF##*/}" + ci: + name: 'CI' + needs: + - extract-branch + uses: maptiler/tileserver-gl/.github/workflows/ci.yml@main + automerger: + name: 'Auto Merge Bot PRs' + needs: + - ci + if: ${{ github.event_name == 'pull_request' && github.event.pull_request.user.login == 'dependabot[bot]' }} + uses: maptiler/tileserver-gl/.github/workflows/automerger.yml@main + builder: + name: 'Build & Publish Docker Image(s)' + needs: + - extract-branch + - ci + if: ${{ github.event_name == 'push' }} + uses: maptiler/tileserver-gl/.github/workflows/builder.yml@main + with: + branch: ${{ needs.extract-branch.outputs.current_branch }}