name: Docker on: push: branches: [ "main" ] # Publish semver tags as releases. tags: [ 'v*.*.*' ] pull_request: branches: [ "main" ] env: REGISTRY: ${{ forgejo.server_url }} IMAGE_NAME: ${{ forgejo.repository }} jobs: build: runs-on: ubuntu-docker container: volumes: - /var/run/docker.sock:/var/run/docker.sock steps: - name: Checkout repository uses: https://code.forgejo.org/actions/checkout@v4 # Set up BuildKit Docker container builder to be able to build # multi-platform images and export cache # https://github.com/docker/setup-buildx-action - name: Set up Docker Buildx uses: https://github.com/docker/setup-buildx-action@v3 # Login against the Forgejo container registry except on PR # https://github.com/docker/login-action - name: Log into registry ${{ env.REGISTRY }} if: forgejo.event_name != 'pull_request' uses: https://github.com/docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ forgejo.actor }} password: ${{ secrets.FORGEJO_TOKEN }} # Extract metadata (tags, labels) for Docker # https://github.com/docker/metadata-action - name: Extract Docker metadata id: meta uses: https://github.com/docker/metadata-action@v5 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: https://github.com/docker/build-push-action@v5 with: context: . push: ${{ forgejo.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }}