name: Build and Push Docker Image on: push: branches: - main paths-ignore: - 'README.md' - '.cnb.yml' - '.gitignore' - '.github/workflows/clean-up.yml' - '.cnb/web_trigger.yml' pull_request: branches: - main paths-ignore: - 'README.md' - '.gitignore' - '.cnb.yml' - '.github/workflows/clean-up.yml' - '.cnb/web_trigger.yml' permissions: contents: read packages: write id-token: write actions: write jobs: build: runs-on: ubuntu-latest if: github.event.repository.fork == false steps: - name: Checkout repository uses: actions/checkout@v2 - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Log into GHCR uses: docker/login-action@master with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ github.token }} - name: Login to Docker Hub uses: docker/login-action@v3 with: username: ${{ vars.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: set lower case owner name run: | echo "OWNER_LC=${OWNER,,}" >>${GITHUB_ENV} env: OWNER: "${{ github.repository_owner }}" - name: Build and push Docker image uses: docker/build-push-action@v5 with: context: . platforms: linux/amd64,linux/arm64/v8 file: ./Dockerfile push: true tags: | ghcr.io/${{ env.OWNER_LC }}/i-tools:latest ${{ vars.DOCKERHUB_USERNAME }}/i-tools:latest - name: Post build cleanup run: docker builder prune --force