From ae49d411f30841f96102b3862c8d13ebdd58808c Mon Sep 17 00:00:00 2001 From: Tnix Date: Tue, 13 Aug 2024 21:32:42 +1200 Subject: [PATCH] Update and rename build-and-push-main.yml to publish-ghcr.yml --- .github/workflows/build-and-push-main.yml | 26 ----------------------- .github/workflows/publish-ghcr.yml | 24 +++++++++++++++++++++ 2 files changed, 24 insertions(+), 26 deletions(-) delete mode 100644 .github/workflows/build-and-push-main.yml create mode 100644 .github/workflows/publish-ghcr.yml diff --git a/.github/workflows/build-and-push-main.yml b/.github/workflows/build-and-push-main.yml deleted file mode 100644 index 6c91c6e..0000000 --- a/.github/workflows/build-and-push-main.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Build and Push Docker Image - -on: - push: - branches: [ "main" ] - -jobs: - - build: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Build image - run: | - IMAGE_NAME=ghcr.io/${{ github.repository }} - docker build -t $IMAGE_NAME:${{ github.sha }} -t $IMAGE_NAME:latest . - - name: Login to GHCR.io - run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin - - - name: Push the image to GHCR.io - run: | - IMAGE_NAME=ghcr.io/${{ github.repository }} - docker push ghcr.io/${{ github.repository }}:${{ github.sha }} - docker push ghcr.io/${{ github.repository }}:latest diff --git a/.github/workflows/publish-ghcr.yml b/.github/workflows/publish-ghcr.yml new file mode 100644 index 0000000..3805feb --- /dev/null +++ b/.github/workflows/publish-ghcr.yml @@ -0,0 +1,24 @@ +name: Publish to GHCR.io + +on: + push: + branches: [ "*" ] + +jobs: + + build: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GHCR.io + run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin + + - name: Build and push images + run: | + IMAGE_NAME=ghcr.io/${{ github.repository }} + docker buildx build --push -t $IMAGE_NAME:${{ github.sha }} -t $IMAGE_NAME:latest .