Image Publisher #19
Workflow file for this run
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: Image Publisher | |
on: | |
release: | |
types: [ published ] | |
jobs: | |
setup-build-push: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.release.tag_name }} | |
- name: Get terraria release | |
id: get_terraria_release | |
run: | | |
TERRARIA=$(echo "${{ github.event.release.tag_name }}" | awk -F'-' '{print $1}') | |
TERRARIAFIX=$(echo \"$TERRARIA\" | jq 'gsub("\\."; "")') | |
echo "Latest terraria release is ${TERRARIA}" | |
echo "latest_terraria=$TERRARIA" >> "$GITHUB_OUTPUT" | |
echo "latest_terraria_fix=$TERRARIAFIX" >> "$GITHUB_OUTPUT" | |
- name: Check if version already exists | |
run: | | |
CHECK=$(curl -s "https://hub.docker.com/v2/repositories/passivelemon/terraria-docker/tags/${{ github.event.release.tag_name }}") | |
echo $CHECK | |
if echo "${CHECK}" | jq -e ".digest" > /dev/null; then | |
echo "Version ${{ github.event.release.tag_name }} already exists. Stopping..." | |
exit 1 | |
fi | |
echo "Version ${{ github.event.release.tag_name }} does not already exist. Continuing..." | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker & GHCR | |
run: | | |
echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin | |
echo "${{ secrets.GHCR_PASSWORD }}" | docker login ghcr.io -u "${{ secrets.GHCR_USERNAME }}" --password-stdin | |
- name: Build the image | |
run: | | |
docker buildx create --name mainbuilder --driver docker-container --platform linux/amd64,linux/arm64 --use | |
docker buildx build --push \ | |
--build-arg TERRARIAVERSION=${{ steps.get_terraria_release.outputs.latest_terraria }} \ | |
--build-arg TERRARIAVERSIONFIX=${{ steps.get_terraria_release.outputs.latest_terraria_fix }} \ | |
--provenance=false \ | |
--platform linux/amd64,linux/arm64 \ | |
--tag ${{ secrets.DOCKER_USERNAME }}/terraria-docker:${{ steps.get_terraria_release.outputs.latest_terraria }} \ | |
--tag ${{ secrets.DOCKER_USERNAME }}/terraria-docker:latest \ | |
--tag ghcr.io/${{ secrets.GHCR_USERNAME }}/terraria-docker:${{ steps.get_terraria_release.outputs.latest_terraria }} \ | |
--tag ghcr.io/${{ secrets.GHCR_USERNAME }}/terraria-docker:latest \ | |
. |