From 784194bad6b48123b83f7cad767cb2be041cb2af Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Thu, 13 Apr 2023 01:30:14 +0200 Subject: [PATCH] Automatically publish Docker images on GitHub --- .github/workflows/docker.yml | 62 ++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 .github/workflows/docker.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 00000000..8317a7b2 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,62 @@ +name: Build Docker images for Blue Nebula server + +on: + push: + tags: + - "*" + branches: + - "*" + pull_request: + branches: + - master + +jobs: + build-and-push: + runs-on: ubuntu-latest + + permissions: + contents: read + packages: write + + steps: + - uses: actions/checkout@v3 + + - name: Fetch relevant submodules + run: | + git submodule update --init src/enet + git submodule update --init data/maps + + - name: Log in to the Container registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + images: | + ghcr.io/blue-nebula/server + tags: | + type=semver,pattern={{version}},event=tag + type=ref,event=branch + type=sha + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Build and push Docker images + uses: docker/build-push-action@v3 + with: + context: . + file: docker/Dockerfile + # enable arm64 once native runners are available + #platforms: linux/amd64,linux/arm64 + platforms: linux/amd64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }}