name: Build on: push: branches: ["main"] # Publish semver tags as releases. tags: ["v*.*.*"] pull_request: branches: ["main"] schedule: - cron: "0 1 * * *" workflow_dispatch: env: # # Use docker.io for Docker Hub if empty REGISTRY: gitea.marijndoeve.nl # github.repository as / IMAGE_NAME: ${{ gitea.repository }} jobs: build: name: Build Image runs-on: ubuntu-latest permissions: contents: read packages: write steps: - name: Checkout repository uses: actions/checkout@v3 # Workaround: https://gitea.com/docker/build-push-action/issues/461 - name: Setup Docker buildx uses: docker/setup-buildx-action@v2 # Login against a Docker registry except on PR # https://github.com/docker/login-action - name: Log into registry ${{ env.REGISTRY }} if: gitea.event_name != 'pull_request' uses: docker/login-action@v2 with: registry: ${{ env.REGISTRY }} username: ${{ gitea.actor }} password: ${{ secrets.GITEA_TOKEN }} # Extract metadata (tags, labels) for Docker # https://github.com/docker/metadata-action # - name: Extract Docker metadata # id: meta # uses: docker/metadata-action@v4 # with: # images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} # Build and push Docker image with Buildx (don't push on PR) # https://github.com/docker/build-push-action - name: Build and push Docker image id: build-and-push uses: docker/build-push-action@v3 with: context: . file: docker/web/Containerfile push: ${{ gitea.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max