name: Build and Push on: push: branches: - main workflow_dispatch: jobs: build_and_push: name: Build and Push runs-on: ubuntu-latest strategy: matrix: database: [mysql, postgres, sqlite] permissions: packages: write contents: read steps: - name: Check out the repo uses: actions/checkout@v4 - name: Login to Docker Hub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Login to GitHub Container Registry uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Extract metadata for Docker id: meta uses: docker/metadata-action@v5 with: images: | sunwuyuan/classworks ghcr.io/ZeroCatDev/ClassworksServer tags: | type=sha,suffix=-${{ matrix.database }} type=raw,value=${{ matrix.database }},enable=${{ github.ref == format('refs/heads/{0}', 'main') }} flavor: | latest=false - name: Build and push Docker images uses: docker/build-push-action@v5 with: context: . build-args: | DATABASE_TYPE=${{ matrix.database }} push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }}