Skip to content

Commit

Permalink
feat: setup dependabot
Browse files Browse the repository at this point in the history
  • Loading branch information
Jomik committed Jan 13, 2024
1 parent cad9125 commit 2ad90e7
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 9 deletions.
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "daily"
5 changes: 3 additions & 2 deletions .github/workflows/build-and-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ on:
- "Dockerfile"
- "screeps-cli.js"
- "screeps-start.js"
- "package.json"
- "package-lock.json"
tags:
- "v*.*.*"
Expand All @@ -30,6 +29,7 @@ jobs:
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
if: ${{ github.event_name != 'pull_request' }}
with:
github-token: ${{ github.token }}
flavor: |
Expand All @@ -39,20 +39,21 @@ jobs:
${{ secrets.DOCKER_HUB_USERNAME }}/screeps-server
tags: |
type=edge,branch=main
type=ref,event=pr
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }}
type=sha
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
if: ${{ github.event_name != 'pull_request' }}
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
build-args: |
NODE_VERSION=${{ matrix.node }}
cache-from: type=gha
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Dependabot auto-approve
on: pull_request_target
permissions:
pull-requests: write
jobs:
dependabot:
runs-on: ubuntu-latest
# Checking the author will prevent your Action run failing on non-Dependabot PRs
if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' }}
steps:
- name: Dependabot metadata
id: dependabot-metadata
uses: dependabot/fetch-metadata@v1
- uses: actions/checkout@v4
- name: Enable auto-merge for Dependabot PRs
if: ${{
contains(steps.dependabot-metadata.outputs.dependency-names, 'screeps') &&
contains(fromJSON('["version-update:semver-patch", "version-update:semver-minor"]'), steps.dependabot-metadata.outputs.update-type)
}}
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Approve a PR if not already approved
run: |
gh pr checkout "$PR_URL" # sets the upstream metadata for `gh pr status`
if [ "$(gh pr status --json reviewDecision -q .currentBranch.reviewDecision)" != "APPROVED" ];
then gh pr review --approve "$PR_URL"
else echo "PR already approved, skipping additional approvals to minimize emails/notification noise.";
fi
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
2 changes: 0 additions & 2 deletions .tool-versions

This file was deleted.

7 changes: 2 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
ARG NODE_VERSION=10
# TODO: Specify this in pipeline.
# Setup pipelines to run on npm hook.
# Requires proxy...
ARG SCREEPS_VERSION=latest
FROM node:${NODE_VERSION}-alpine as screeps

# Install node-gyp dependencies
Expand All @@ -14,8 +10,9 @@ RUN --mount=type=cache,target=/etc/apk/cache \

# Install screeps
WORKDIR /screeps
COPY package.json package-lock.json ./
RUN --mount=type=cache,target=/root/.npm \
npm install --save-exact "screeps@${SCREEPS_VERSION}" "[email protected]"
npm clean-install

# Initialize screeps, similar to `screeps init`
RUN cp -a /screeps/node_modules/@screeps/launcher/init_dist/.screepsrc ./ && \
Expand Down

0 comments on commit 2ad90e7

Please sign in to comment.