figure out how to build a container, and push it to the forgejo registry #53

Open
opened 2025-10-26 14:00:52 +01:00 by dan · 0 comments
Owner

To upload to the generic registry, I can use something along these lines in a workflow:

      - name: "Upload to registry"
        run: |
          TAG_VERSION="$(git tag | tail -n 1)"
          PREFIX="${{ env.FORGEJO_REPOSITORY_OWNER}}/"
          FULL_REPO="${{ env.FORGEJO_REPOSITORY }}"
          REPO=${FULL_REPO#"$PREFIX"}
          API_SUFFIX="/v1"
          API_WITH_SUFFIX=${{ env.FORGEJO_API_URL }}
          API_URL=${API_WITH_SUFFIX%"$API_SUFFIX"}
           TARBALL="build.tar.gz"
          tar -cvzf $TARBALL build
          USER_PASS="${{ env.FORGEJO_REPOSITORY_OWNER }}:${{ secrets.PASS }}"
          URL="$API_URL/packages/${{ env.FORGEJO_REPOSITORY_OWNER }}/generic/$REPO/$TAG_VERSION/$TARBALL"
          curl --user "${{ env.FORGEJO_REPOSITORY_OWNER }}:${{ secrets.PASS }}" \
                 --upload-file $TARBALL $URL

Note that it's unclear what happens if:

  • A previous tag is amended and pushed
  • A tag contains a / in its name (could I decide to disallow those tags?)

Note that for t his to work, you need to:

  • Add a PASS secret to the repository that gives the repository user access to forgejo's package registry.
  • Tag releases properly, e.g. git tag -a 1.0.1 -m "New patch".
To upload to the generic registry, I can use something along these lines in a workflow: ```yaml - name: "Upload to registry" run: | TAG_VERSION="$(git tag | tail -n 1)" PREFIX="${{ env.FORGEJO_REPOSITORY_OWNER}}/" FULL_REPO="${{ env.FORGEJO_REPOSITORY }}" REPO=${FULL_REPO#"$PREFIX"} API_SUFFIX="/v1" API_WITH_SUFFIX=${{ env.FORGEJO_API_URL }} API_URL=${API_WITH_SUFFIX%"$API_SUFFIX"} TARBALL="build.tar.gz" tar -cvzf $TARBALL build USER_PASS="${{ env.FORGEJO_REPOSITORY_OWNER }}:${{ secrets.PASS }}" URL="$API_URL/packages/${{ env.FORGEJO_REPOSITORY_OWNER }}/generic/$REPO/$TAG_VERSION/$TARBALL" curl --user "${{ env.FORGEJO_REPOSITORY_OWNER }}:${{ secrets.PASS }}" \ --upload-file $TARBALL $URL ``` Note that it's unclear what happens if: - A previous tag is amended and pushed - A tag contains a `/` in its name (could I decide to disallow those tags?) Note that for t his to work, you need to: - Add a `PASS` secret to the repository that gives the repository user access to forgejo's package registry. - Tag releases properly, e.g. `git tag -a 1.0.1 -m "New patch"`.
dan added this to the siteinspector project 2025-10-26 14:00:59 +01:00
Sign in to join this conversation.
No description provided.