name: Docker CI/CD on: push: branches: - '**' release: types: - published permissions: packages: write contents: read jobs: build: runs-on: ubuntu-latest if: github.event_name == 'push' steps: - name: Checkout code uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - name: Build Docker image run: | IMAGE_NAME=$(echo ${{ github.repository }} | cut -d'/' -f2) docker build -t $IMAGE_NAME:${{ github.sha }} . - name: Save Docker image as .tar artifact run: | IMAGE_NAME=$(echo ${{ github.repository }} | cut -d'/' -f2) docker save $IMAGE_NAME:${{ github.sha }} > docker-image-${{ github.sha }}.tar - name: Upload artifact uses: actions/upload-artifact@v4 # Updated to v4 with: name: docker-image-${{ github.sha }} path: docker-image-${{ github.sha }}.tar