included additional gitignore references #16
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
name: Terraria Container Image | |
on: | |
push: | |
branches: | |
- main | |
env: | |
REGISTRY: ghcr.io | |
jobs: | |
terraria-image-update: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Check if Dockerfile has changed | |
id: changed-dockerfile | |
uses: tj-actions/changed-files@v35 | |
with: | |
files: | | |
servers/terraria/image/Dockerfile | |
# Workaround: https://github.com/docker/build-push-action/issues/461 | |
- name: Setup Docker buildx | |
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf | |
if: steps.changed-dockerfile.outputs.any_changed == 'true' | |
- name: Log into registry ${{ env.REGISTRY }} | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ secrets.GH_USER }} | |
password: ${{ secrets.GH_TOKEN }} | |
- name: Extract TERRARIA_VERSION from Dockerfile | |
if: steps.changed-dockerfile.outputs.any_changed == 'true' | |
id: terraria_version | |
run: | | |
TERRARIA_VERSION=$(grep "ARG TERRARIA_VERSION" ./servers/terraria/image/Dockerfile | cut -d'=' -f2) | |
echo "TERRARIA_VERSION=$TERRARIA_VERSION" | |
echo "TERRARIA_VERSION=$TERRARIA_VERSION" >> $GITHUB_ENV | |
# Build and push Docker image with Buildx (don't push on PR) | |
# https://github.com/docker/build-push-action | |
- name: Build and push Docker image | |
if: steps.changed-dockerfile.outputs.any_changed == 'true' | |
id: build-and-push | |
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a | |
with: | |
context: ./servers/terraria/image | |
push: true | |
tags: ghcr.io/${{ github.repository_owner }}/terraria:v${{ env.TERRARIA_VERSION }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max |