diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index e95b6c7..a2528d6 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,4 +1,4 @@ -name: Build and Push Docker Image +name: Build and Push Multi-Arch Docker Image on: push: @@ -9,26 +9,34 @@ on: jobs: build-and-push: runs-on: ubuntu-latest + + permissions: + contents: read + packages: write + steps: - - uses: actions/checkout@v3 + - name: Checkout code + uses: actions/checkout@v3 - - name: Build the Docker image - run: docker build . --file Dockerfile --tag atridad:${{ github.sha }} + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 - - name: Install doctl - uses: digitalocean/action-doctl@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 with: - token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} - - name: Log in to DO Container Registry - run: doctl registry login --expiry-seconds 600 - - - name: Tag images - run: | - docker tag atridad:${{ github.sha }} ${{ secrets.DIGITALOCEAN_REGISTRY }}:${{ github.sha }} - docker tag atridad:${{ github.sha }} ${{ secrets.DIGITALOCEAN_REGISTRY }}:latest - - - name: Push images to DO Container Registry - run: | - docker push ${{ secrets.DIGITALOCEAN_REGISTRY }}:${{ github.sha }} - docker push ${{ secrets.DIGITALOCEAN_REGISTRY }}:latest + - name: Build and push + uses: docker/build-push-action@v4 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: | + ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ github.sha }} + ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:latest