Browse Source

update github actions to build docker image

Nick Sweeting 1 year ago
parent
commit
b78e892bf8
1 changed files with 30 additions and 9 deletions
  1. 30 9
      .github/workflows/docker.yml

+ 30 - 9
.github/workflows/docker.yml

@@ -18,9 +18,9 @@ jobs:
     steps:
     steps:
       - name: Checkout
       - name: Checkout
         uses: actions/checkout@v4
         uses: actions/checkout@v4
-        with:
-          submodules: true
-          fetch-depth: 1
+        # with:
+        #   submodules: true
+        #   fetch-depth: 1
 
 
       - name: Set up QEMU
       - name: Set up QEMU
         uses: docker/setup-qemu-action@v3
         uses: docker/setup-qemu-action@v3
@@ -40,26 +40,34 @@ jobs:
         run: echo ${{ steps.buildx.outputs.platforms }}
         run: echo ${{ steps.buildx.outputs.platforms }}
 
 
       - name: Cache Docker layers
       - name: Cache Docker layers
-        uses: actions/cache@v3
+        uses: actions/cache@v4
         with:
         with:
           path: /tmp/.buildx-cache
           path: /tmp/.buildx-cache
           key: ${{ runner.os }}-buildx-${{ github.sha }}
           key: ${{ runner.os }}-buildx-${{ github.sha }}
           restore-keys: |
           restore-keys: |
             ${{ runner.os }}-buildx-
             ${{ runner.os }}-buildx-
 
 
-      - name: Docker Login
+      - name: Login to Docker Hub
         uses: docker/login-action@v3
         uses: docker/login-action@v3
         if: github.event_name != 'pull_request'
         if: github.event_name != 'pull_request'
         with:
         with:
           username: ${{ secrets.DOCKER_USERNAME }}
           username: ${{ secrets.DOCKER_USERNAME }}
           password: ${{ secrets.DOCKER_PASSWORD }}
           password: ${{ secrets.DOCKER_PASSWORD }}
 
 
-      - name: Collect Docker tags
+      - name: Login to GitHub Container Registry
+        uses: docker/login-action@v3
+        with:
+          registry: ghcr.io
+          username: ${{ github.actor }}
+          password: ${{ secrets.GITHUB_TOKEN }}
+
+      - name: Collect Full Release Docker tags
         # https://github.com/docker/metadata-action
         # https://github.com/docker/metadata-action
         id: docker_meta
         id: docker_meta
         uses: docker/metadata-action@v5
         uses: docker/metadata-action@v5
+        if: github.event_name == 'workflow_dispatch'
         with:
         with:
-          images: archivebox/archivebox,nikisweeting/archivebox
+          images: archivebox/archivebox,ghcr.io/archivebox/archivebox
           tags: |
           tags: |
               # :stable
               # :stable
               type=ref,event=branch
               type=ref,event=branch
@@ -71,6 +79,19 @@ jobs:
               type=sha
               type=sha
               # :latest
               # :latest
               type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'stable') }}
               type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'stable') }}
+      
+      - name: Collect Non-Release Docker tags
+        # https://github.com/docker/metadata-action
+        id: docker_meta_non_release
+        uses: docker/metadata-action@v5
+        if: github.event_name != 'workflow_dispatch'
+        with:
+          images: archivebox/archivebox,ghcr.io/archivebox/archivebox
+          tags: |
+              # :stable
+              type=ref,event=branch
+              # :sha-463ea54
+              type=sha
 
 
       - name: Build and push
       - name: Build and push
         id: docker_build
         id: docker_build
@@ -80,8 +101,8 @@ jobs:
           file: ./Dockerfile
           file: ./Dockerfile
           builder: ${{ steps.buildx.outputs.name }}
           builder: ${{ steps.buildx.outputs.name }}
           push: ${{ github.event_name != 'pull_request' }}
           push: ${{ github.event_name != 'pull_request' }}
-          tags: ${{ steps.docker_meta.outputs.tags }}
-          labels: ${{ steps.docker_meta.outputs.labels }}
+          tags: ${{ github.event_name == 'workflow_dispatch' ? steps.docker_meta.outputs.tags : steps.docker_meta_non_release.outputs.tags }}
+          labels: ${{ github.event_name == 'workflow_dispatch' ? steps.docker_meta.outputs.labels : steps.docker_meta_non_release.outputs.labels }}
           cache-from: type=local,src=/tmp/.buildx-cache
           cache-from: type=local,src=/tmp/.buildx-cache
           cache-to: type=local,dest=/tmp/.buildx-cache-new
           cache-to: type=local,dest=/tmp/.buildx-cache-new
           platforms: linux/amd64,linux/arm64
           platforms: linux/amd64,linux/arm64