-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from fpiesche/master
Automatically update Docker images
- Loading branch information
Showing
2 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
version: 2 | ||
updates: | ||
# Automatically update base images in Dockerfiles if available | ||
- package-ecosystem: docker | ||
directory: / | ||
schedule: | ||
interval: "daily" | ||
# Also automatically update any Github Actions used in the workflow | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
name: Build Docker images | ||
|
||
on: | ||
# Allow manual runs. | ||
workflow_dispatch: | ||
# Also run on updates to this repo. | ||
push: | ||
branches: | ||
- main | ||
paths-ignore: | ||
- '**/*.md' | ||
# Run on PRs except for documentation. | ||
pull_request: | ||
paths-ignore: | ||
- '**/*.md' | ||
|
||
env: | ||
IMAGE_NAME: starbound-server | ||
# This doesn't apply to Starbound but to build a multi-arch Docker image you can | ||
# set multiple platforms like this: | ||
# PLATFORMS: linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/amd64 | ||
PLATFORMS: linux/amd64 | ||
# Only push the image on merges to main | ||
PUSH_IMAGE: ${{ github.ref == 'refs/heads/master' }} | ||
|
||
jobs: | ||
|
||
build-image: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Set datestamp for image tagging | ||
run: | | ||
echo DATESTAMP=$(date +%Y.%m.%d) >> $GITHUB_ENV | ||
- name: Docker Setup QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
|
||
- name: Docker Setup Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Login to DockerHub | ||
if: ${{ env.PUSH_IMAGE == 'true' }} | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Login to GitHub Container Registry | ||
if: ${{ env.PUSH_IMAGE == 'true' }} | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GHCR_TOKEN }} | ||
|
||
- name: Build and push ${{ env.IMAGE_NAME }} Docker image | ||
uses: docker/build-push-action@v2 | ||
with: | ||
tags: | | ||
${{ secrets.DOCKERHUB_USERNAME || 'nobody' }}/${{ env.IMAGE_NAME }}:latest | ||
ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:latest | ||
${{ secrets.DOCKERHUB_USERNAME || 'nobody' }}/${{ env.IMAGE_NAME }}:v${{ env.DATESTAMP }} | ||
ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:v${{ env.DATESTAMP }} | ||
platforms: ${{ env.PLATFORMS }} | ||
push: ${{ env.PUSH_IMAGE }} |