diff --git a/.gitea/workflows/docker.yaml b/.gitea/workflows/docker.yaml index e4e566e..c59abec 100644 --- a/.gitea/workflows/docker.yaml +++ b/.gitea/workflows/docker.yaml @@ -1,38 +1,43 @@ -name: Build and push docker image -run-name: Building docker image and push them to git.dacremont.xyz +name: build and push docker image +run-name: building docker image and push them to git.dacremont.xyz on: workflow_dispatch: {} push: branches: [ "main" ] paths: - - 'Dockerfile' - # Publish semver tags as releases. + - 'dockerfile' + # publish semver tags as releases. tags: [ 'v*.*.*' ] env: - # Use docker.io for Docker Hub if empty - REGISTRY: git.dacremont.xyz + # use docker.io for docker hub if empty + registry: git.dacremont.xyz # gitea.repository as / - IMAGE_NAME: ${{ gitea.repository }} + image_name: ${{ gitea.repository }} jobs: - Build-and-push-docker: + build-and-push-docker: runs-on: ubuntu-latest container: ghcr.io/catthehacker/ubuntu:act-latest permissions: contents: read packages: write - # This is used to complete the identity challenge - # with sigstore/fulcio when running outside of PRs. + # this is used to complete the identity challenge + # with sigstore/fulcio when running outside of prs. id-token: write steps: - - name: Checkout repository + - name: checkout repository uses: actions/checkout@v4 - - name: Restore Docker cache + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + driver: docker-container + + - name: restore docker cache uses: actions/cache@v3 with: path: /tmp/.buildx-cache @@ -40,16 +45,16 @@ jobs: restore-keys: | ${{ runner.os }}-buildx- - # Login against a Docker registry except on PR - # https://`.com/docker/login-action - - name: Log into registry ${{ env.REGISTRY }} + # login against a docker registry except on pr + # https://`.com/docker/login-action + - name: log into registry ${{ env.registry }} uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 with: - registry: ${{ env.REGISTRY }} + registry: ${{ env.registry }} username: ${{ secrets.username }} - password: ${{ secrets.TOKEN }} + password: ${{ secrets.token }} - - name: Build and push docker image + - name: build and push docker image uses: docker/build-push-action@v4 with: context: . @@ -57,8 +62,13 @@ jobs: pull: true no-cache: true tags: | - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ gitea.sha }} - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest + ${{ env.registry }}/${{ env.image_name }}:${{ gitea.sha }} + ${{ env.registry }}/${{ env.image_name }}:latest cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache + - name: move exported cache back (workaround) + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache +