aboutsummaryrefslogtreecommitdiffstats
path: root/.gitea/workflows/build.yaml
blob: 062a123276921185ba9bcf5af6fe7e54b8148033 (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
name: "lint, build and push"
on:
  schedule:
    - cron: "49 9 * * SUN"
  push:
    branches: [ master ]
  pull_request:

# Variables: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables#default-environment-variables + https://forgejo.org/docs/latest/user/actions/#env-1

jobs:
  lint:
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
      - name: Run Gitleaks
        uses: docker://zricethezav/gitleaks:v8.21.0
        with:
          args: detect --no-git --verbose --source ${{ github.workspace }}
      - name: Run hadolint
        uses: docker://pipelinecomponents/hadolint:0.26.4
        with:
          args: hadolint Dockerfile
#      - name: Run ShellCheck
#        uses: sudo-bot/action-shellcheck@latest
#        with:
#          cli-args: "shell.sh"
      - name: Send notification
        uses: dawidd6/action-send-mail@v3
        if: failure()
        with:
          connection_url: smtp://docker10.mgrote.net:1025
          secure: false
          ignore_cert: true
          to: michael.grote@posteo.de
          from: Gitea Actions <gitea@mgrote.net>
          subject: "CI ${{ job.status }} in ${{ github.repository }}"
          body: |
            Repo: ${{ github.repository }}
            Job: ${{ github.action }}
            Status: ${{ job.status }}
            Source: ${{ github.head_ref }}

  build:
    needs: [gitleaks, hadolint] # shellcheck
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
      - name: Extract repository name
        id: name
        run: |
          echo REPO_NAME=$(echo ${GITHUB_REPOSITORY} | awk -F"/" '{print $2}') >> $GITHUB_OUTPUT
      - name: Docker meta
        id: meta
        uses: docker/metadata-action@v5
        with:
          images: |
            registry.mgrote.net/${{ steps.name.outputs.REPO_NAME }}
          tags: |
            type=raw,value=latest,enable={{is_default_branch}}
            type=ref,event=branch
            type=ref,event=pr
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3
#      - name: Login to Docker Hub
#        uses: docker/login-action@v3
#        with:
#          username: ${{ secrets.DOCKERHUB_USERNAME }}
#          password: ${{ secrets.DOCKERHUB_TOKEN }}
      - name: Build and push Docker image
        uses: https://github.com/docker/build-push-action@v6
        with:
          context: .
          file: ./Dockerfile
          push: true
          tags: ${{ steps.meta.outputs.tags }}
      - name: Send notification
        uses: dawidd6/action-send-mail@v3
        if: failure()
        with:
          connection_url: smtp://docker10.mgrote.net:1025
          secure: false
          ignore_cert: true
          to: michael.grote@posteo.de
          from: Gitea Actions <gitea@mgrote.net>
          subject: "CI ${{ job.status }} in ${{ github.repository }}"
          body: |
            Repo: ${{ github.repository }}
            Job: ${{ github.action }}
            Status: ${{ job.status }}
            Source: ${{ github.head_ref }}