Read-only mirror — the public repositories of the Forgejo instance, refreshed every 10 minutes. The live instance (fg.dieschoenewolke.de) is reachable only over the VPN; clone here with https://git.dieschoenewolke.de/git/<owner>/<repo>.git.
summaryrefslogtreecommitdiff
path: root/.github/workflows/update-test-ubuntu-git.yml
blob: ace00bb27ec13e19a47b93e646bcf484ad3439b9 (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
name: Publish test-ubuntu-git Container

on:
  # Use an on demand workflow trigger.  
  # (Forked copies of actions/checkout won't have permission to update GHCR.io/actions, 
  #  so avoid trigger events that run automatically.)
  workflow_dispatch:
    inputs:
      publish:
        description:  'Publish to ghcr.io? (main branch only)'
        type: boolean
        required: true
        default: false

env:
  REGISTRY: ghcr.io
  IMAGE_NAME: actions/test-ubuntu-git

jobs:
  build-and-push-image:
    runs-on: ubuntu-latest
    # Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
    permissions:
      contents: read
      packages: write
 
    steps:
      - name: Checkout repository
        uses: actions/checkout@v7

      # Use `docker/login-action` to log in to GHCR.io. 
      # Once published, the packages are scoped to the account defined here.
      - name: Log in to the ghcr.io container registry
        uses: docker/login-action@v4.6.0
        with:
          registry: ${{ env.REGISTRY }}
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}

      - name: Format Timestamp
        id: timestamp
        # Use `date` with a custom format to achieve the key=value format GITHUB_OUTPUT expects.
        run: date -u "+now=%Y%m%d.%H%M%S.%3NZ" >> "$GITHUB_OUTPUT"

      - name: Issue Image Publish Warning
        if:  ${{ inputs.publish && github.ref_name != 'main' }}
        run: echo "::warning::test-ubuntu-git images can only be published from the actions/checkout 'main' branch.  Workflow will continue with push/publish disabled."

      # Use `docker/build-push-action` to build (and optionally publish) the image. 
      - name: Build Docker Image (with optional Push)
        uses: docker/build-push-action@v7.4.0
        with:
          context: .
          file: images/test-ubuntu-git.Dockerfile
          # For now, attempts to push to ghcr.io must target the `main` branch.
          # In the future, consider also allowing attempts from `releases/*` branches.
          push: ${{ inputs.publish && github.ref_name == 'main' }}
          tags: |
            ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}.${{ steps.timestamp.outputs.now }}