Skip to content

Commit

Permalink
chore: deploy to ghcr.io instead
Browse files Browse the repository at this point in the history
  • Loading branch information
Jomik committed Feb 15, 2024
1 parent a54ab5b commit 4c8f3dd
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 35 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Build docker image

on:
workflow_dispatch:

pull_request:
branches:
- "main"

jobs:
release:
runs-on: ubuntu-latest
strategy:
matrix:
node: [10, 12]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
build-args: |
NODE_VERSION=${{ matrix.node }}
cache-from: type=gha
cache-to: type=gha,mode=max
Original file line number Diff line number Diff line change
@@ -1,62 +1,62 @@
name: Build and push to Docker Hub
name: Deploy Images to GHCR

on:
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

on:
push:
paths:
- "Dockerfile"
- "screeps-cli.js"
- "screeps-start.js"
- "package-lock.json"
tags:
- "v*.*.*"
branches:
- "main"
pull_request:
branches:
- "main"
- main
tags:
- "v*"
release:
types:
- published

workflow_dispatch:

jobs:
release:
push-image:
runs-on: ubuntu-latest
strategy:
matrix:
node: [10, 12]
permissions:
contents: read
packages: write
steps:
- name: Checkout
- name: "Checkout GitHub Action"
uses: actions/checkout@v4
- name: Docker meta
- name: Log in to the Container registry
uses: docker/login-action@3d58c274f17dffee475a5520cbe67f0a882c4dbb
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
if: ${{ github.event_name != 'pull_request' }}
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
github-token: ${{ github.token }}
flavor: |
latest=auto
suffix=${{ matrix.node != 10 && format('-node{0}', matrix.node) || '' }},onlatest=true
images: |
${{ secrets.DOCKER_HUB_USERNAME }}/screeps-server
tags: |
type=edge,branch=main
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
- name: Build and push Docker image
uses: docker/build-push-action@4976231911ebf5f32aad765192d35f942aa48cb8
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
push: true
build-args: |
NODE_VERSION=${{ matrix.node }}
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
2 changes: 2 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5
with:
publish: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3"
services:
screeps:
platform: linux/x86_64
image: jomik/screeps-server:edge
image: ghcr.io/jomik/screeps-server:edge
depends_on:
- mongo
- redis
Expand Down

0 comments on commit 4c8f3dd

Please sign in to comment.