From ba44213886223852025c776bbf4bdee0ec7958d2 Mon Sep 17 00:00:00 2001 From: chadmin Date: Tue, 22 Oct 2024 19:41:56 -0700 Subject: [PATCH] update workflow --- .github/workflows/gitmotion-docker-image.yml | 53 +++++++++----------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/.github/workflows/gitmotion-docker-image.yml b/.github/workflows/gitmotion-docker-image.yml index df8da5042..473a7274b 100644 --- a/.github/workflows/gitmotion-docker-image.yml +++ b/.github/workflows/gitmotion-docker-image.yml @@ -1,11 +1,9 @@ -name: Docker Image Release +name: Build and Push Docker Image -# Trigger workflow when there's a push to the specified branch on: push: branches: - - gitmotion/main # Replace with your target branch (e.g., main or dev) - workflow_dispatch: # Allows manual trigger of the workflow + - gitmotion/main # You can also specify the branch where you want the action to trigger, like `develop`, or your custom branch. jobs: ci: @@ -35,36 +33,35 @@ jobs: runs-on: ubuntu-latest needs: - ci - steps: - - name: Checkout - uses: actions/checkout@v4 # v4 + # Checkout the repository + - name: Checkout repository + uses: actions/checkout@v3 + + # Set up Docker Buildx (to support multi-platform builds) + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 - - name: Login to GitHub Container Registry - uses: docker/login-action@v3 + # Log in to GitHub Container Registry (GHCR) + - name: Log in to GitHub Container Registry + uses: docker/login-action@v2 with: registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - # - name: Login to Docker Hub - # uses: docker/login-action@v3 - # with: - # username: ${{ secrets.DOCKERHUB_USERNAME }} - # password: ${{ secrets.DOCKERHUB_TOKEN }} + username: ${{ secrets.GHCR_USERNAME }} + password: ${{ secrets.GHCR_TOKEN }} - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Build and push Docker images + # Build and push the Docker image + - name: Build and push Docker image uses: docker/build-push-action@v5 with: context: . - file: ./Dockerfile - platforms: linux/amd64,linux/arm64 push: true - tags: | - ghcr.io/gitmotion/it-tools:latest + tags: ghcr.io/${{ secrets.GHCR_USERNAME }}/it-tools:latest + # Optionally add version tags or specific branch tags like: + # tags: | + # ghcr.io/${{ secrets.GHCR_USERNAME }}/your-repo-name:latest + # ghcr.io/${{ secrets.GHCR_USERNAME }}/your-repo-name:${{ github.sha }} + + # Optionally log out + - name: Log out from GitHub Container Registry + run: docker logout ghcr.io