diff --git a/.forgejo/workflows/docker.yml b/.forgejo/workflows/docker.yml index 278a963..02048bf 100644 --- a/.forgejo/workflows/docker.yml +++ b/.forgejo/workflows/docker.yml @@ -1,36 +1,22 @@ name: docker on: - # workflow_run: - # workflows: [crane] push: branches: [main] - # types: - # - completed - # schedule: - # - cron: 0 0 * * 1 - # # Publish semver tags as releases. - # tags: [ 'v*.*.*' ] - # pull_request: - # branches: [ "main" ] env: - # Use docker.io for Docker Hub if empty REGISTRY: git.nexveridian.com - # github.repository as / IMAGE_NAME: ${{ github.repository }} NIX_CONFIG: "experimental-features = nix-command flakes" + # UNCOMMENT BELOW AND ADD PERSONAL ACCESS TOKEN TO SECRETS FOR CONTAINER REGISTRY + # CONTAINER_TOKEN: ${{ secrets.CONTAINER_REGISTRY_TOKEN }} jobs: build: runs-on: docker - # https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#running-a-workflow-based-on-the-conclusion-of-another-workflow - # if: ${{ github.event.workflow_run.conclusion == 'success' }} permissions: contents: read packages: write - # This is used to complete the identity challenge - # with sigstore/fulcio when running outside of PRs. id-token: write steps: @@ -48,46 +34,125 @@ jobs: - uses: actions/checkout@v4 - - name: Install Docker + - name: Install skopeo run: | mkdir -p ~/.local/bin - nix build -I nixpkgs=channel:nixos-unstable nixpkgs#docker -o ~/.local/docker - ln -sf ~/.local/docker/bin/docker ~/.local/bin/docker + nix build -I nixpkgs=channel:nixos-unstable nixpkgs#skopeo -o ~/.local/skopeo + ln -sf ~/.local/skopeo/bin/skopeo ~/.local/bin/skopeo echo "$HOME/.local/bin" >> $GITHUB_PATH - - name: Log into registry ${{ env.REGISTRY }} - if: github.event_name != 'pull_request' - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ env.GITHUB_ACTOR }} - password: ${{ env.GITHUB_TOKEN }} - - - name: Extract Docker metadata - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - - name: Build Nix package run: nix build .#my-docker - # https://github.com/orgs/community/discussions/25768#discussioncomment-3249183 - - name: Downcase REPO + - name: Prepare repository variables run: | echo "REPO=${GITHUB_REPOSITORY,,}" >> ${GITHUB_ENV} + echo "OWNER=${GITHUB_REPOSITORY_OWNER,,}" >> ${GITHUB_ENV} + # Extract just the repository name (everything after the last slash) + REPO_NAME=${GITHUB_REPOSITORY##*/} + echo "IMAGE_NAME=${REPO_NAME,,}" >> ${GITHUB_ENV} - - name: Strip REPO Username - run: | - STRIP_REPO_USERNAME=${REPO#nexveridian/} - echo "STRIP_REPO_USERNAME=${STRIP_REPO_USERNAME}" >> ${GITHUB_ENV} + # Debug output + echo "Full repository: ${GITHUB_REPOSITORY}" + echo "Repository owner: ${GITHUB_REPOSITORY_OWNER}" + echo "Extracted repo name: ${REPO_NAME}" + echo "Final image name: ${REPO_NAME,,}" + echo "Final owner: ${GITHUB_REPOSITORY_OWNER,,}" - # https://github.com/docker/build-push-action/issues/538 - - name: Push and tag Docker image + - name: Setup skopeo policy and push image run: | - docker load < result - docker tag ${{ env.STRIP_REPO_USERNAME }}:latest ${{ env.REGISTRY }}/${{ env.REPO }}:latest - docker push ${{ env.REGISTRY }}/${{ env.REPO }}:latest + # configure container policy to accept insecure registry + mkdir -p ~/.config/containers + cat > ~/.config/containers/policy.json < ~/.docker/config.json <