summaryrefslogtreecommitdiff
path: root/.github/workflows/build-publish-container-image.yml
blob: 279e065557f24dc1a5254e48b085f731c6b4f089 (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
name: Build & Publish Container

on:
  workflow_dispatch:
    inputs:
      tag:
        description: "Build tag"
        required: true
        default: "latest"
        type: string

jobs:
  build_publish:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Build the container image
        run: |
          docker build . --file Containerfile --tag ${{ github.repository }}:${{ github.event.inputs.tag }}
          docker tag ${{ github.repository }}:${{ github.event.inputs.tag }} git.ch-naseem.com/${{ github.repository }}:${{ github.event.inputs.tag }}
          docker tag ${{ github.repository }}:${{ github.event.inputs.tag }} ghcr.io/${{ github.repository }}:${{ github.event.inputs.tag }}

      - name: Publish the image to Docker Hub
        run: |
          echo "${{ secrets.FORGEJO_TOKEN }}" | docker login git.ch-naseem.com -u ${{ github.actor }} --password-stdin
          docker push git.ch-naseem.com/${{ github.repository }}:${{ github.event.inputs.tag }}

      - name: Publish the image to Github Container Registry
        run: |
          echo "${{ secrets.GHCR_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
          docker push ghcr.io/${{ github.repository }}:${{ github.event.inputs.tag }}