summaryrefslogtreecommitdiff
path: root/.forgejo/workflows/docker-ci.yml
blob: 49a885f785286f8721ce555d13913790c6e5e343 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
name: Build and Push Docker Image

on:
  push:
    branches:
      - main
  pull_request:
  workflow_dispatch:

jobs:
  build:
    runs-on: docker

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Build Docker image
        run: docker build -t ${{ env.REPO_URL }}/${{ github.repository }}:latest .

      - name: Tag image with commit SHA
        run: docker tag ${{ env.REPO_URL }}/${{ github.repository }}:latest ${{ env.REPO_URL }}/${{ github.repository }}:${{ github.sha }}

      - name: Login to Forgejo Container Registry
        if: github.event_name != 'pull_request'
        run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ${{ env.REPO_URL }} -u ${{ github.actor }} --password-stdin

      - name: Push Docker images
        if: github.event_name != 'pull_request'
        run: |
          docker push ${{ env.REPO_URL }}/${{ github.repository }}:latest
          docker push ${{ env.REPO_URL }}/${{ github.repository }}:${{ github.sha }}