diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..74923de1a --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,39 @@ +name: build prod container image and push to registry + +on: + push: + branches: + - main + release: + types: + - published + +jobs: + build: + runs-on: ubuntu-latest + name: Build prod container + permissions: + packages: write + contents: read + env: + REGISTRY: ghcr.io + IMAGE: ghcr.io/chocobocoding/teiserver + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Login to registry + run: buildah login -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} $REGISTRY + + - name: Build image + run: buildah bud -t $IMAGE:latest . + + - name: Push latest image + run: buildah push $IMAGE:latest + + - name: Push sha tagged image + run: buildah push $IMAGE:latest $IMAGE:${{ github.sha }} + + - name: Push tagged image + if: github.event_name == 'release' + run: buildah push $IMAGE:latest $IMAGE:${{ github.event.release.tag_name }} \ No newline at end of file