-
-
Notifications
You must be signed in to change notification settings - Fork 0
chore: add Docker deployment support #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7ed15fa
chore: add Docker deployment with multi-registry support
philprime 56c3fe8
Update Makefile
philprime 27d2e8b
Update AGENTS.md
philprime 7690488
Update AGENTS.md
philprime e06fea5
Update .github/workflows/build-cli-docker.yml
philprime ca9b022
Smaller changes
philprime File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| # Git | ||
| .git | ||
| .gitignore | ||
| .gitattributes | ||
|
|
||
| # Build artifacts | ||
| dist/ | ||
| **/dist/ | ||
| # Allow CLI binaries for Docker builds | ||
| !dist/github-actions-utils-cli-linux-* | ||
| build/ | ||
| **/build/ | ||
| *.swp | ||
| *.swo | ||
| *~ | ||
|
|
||
| # Node | ||
| node_modules/ | ||
| **/node_modules/ | ||
| npm-debug.log* | ||
| yarn-debug.log* | ||
| yarn-error.log* | ||
| .npm | ||
| .pnpm-store | ||
|
|
||
| # macOS files | ||
| **/.DS_Store | ||
|
|
||
| # Testing | ||
| coverage/ | ||
| .nyc_output | ||
|
|
||
| # IDE | ||
| .idea/ | ||
| .vscode/ | ||
| *.iml | ||
| *.swp | ||
| *.swo | ||
| *~ | ||
| .DS_Store | ||
|
|
||
| # OS | ||
| Thumbs.db | ||
|
|
||
| # Deployment | ||
| deploy/ | ||
| .pulumi/ | ||
|
|
||
| # Docs | ||
| docs/ | ||
| *.md | ||
| !README.md | ||
|
|
||
| # Examples and tests | ||
| examples/ | ||
| *_test.go | ||
| testdata/ | ||
|
|
||
| # CI/CD | ||
| .github/ | ||
| .gitlab-ci.yml | ||
| .travis.yml | ||
|
|
||
| # Misc | ||
| .env | ||
| .env.* | ||
| !.env.example | ||
| tmp/ | ||
| temp/ | ||
| *.log |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,197 @@ | ||
| name: Build CLI Docker Images | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| tag_name: | ||
| description: "Tag name for Docker images" | ||
| required: true | ||
| type: string | ||
| is_prerelease: | ||
| description: "Whether this is a prerelease" | ||
| required: true | ||
| type: string | ||
|
|
||
| jobs: | ||
| build: | ||
| name: Build CLI Docker Image (${{ matrix.platform.name }}) | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| packages: write | ||
| attestations: write | ||
| id-token: write | ||
| timeout-minutes: 30 | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| platform: | ||
| - name: linux/amd64 | ||
| tag: linux-amd64 | ||
| - name: linux/arm64 | ||
| tag: linux-arm64 | ||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.platform.name }} | ||
| cancel-in-progress: true | ||
|
|
||
| steps: | ||
| - name: Checkout Repository | ||
| uses: actions/checkout@v5 | ||
|
|
||
| - name: Download CLI artifacts | ||
| uses: actions/download-artifact@v6 | ||
| with: | ||
| path: dist | ||
| pattern: cli-${{ matrix.platform.tag }} | ||
| merge-multiple: true | ||
|
|
||
| - name: List downloaded files | ||
| run: ls -lh dist/ | ||
|
|
||
| - name: Set up QEMU | ||
| uses: docker/setup-qemu-action@v3 | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
|
|
||
| - name: Docker meta | ||
| id: meta | ||
| uses: docker/metadata-action@v5 | ||
| with: | ||
| images: | | ||
| docker.io/${{ github.repository }} | ||
| ghcr.io/${{ github.repository }} | ||
| tags: | | ||
| type=raw,value=${{ inputs.tag_name }} | ||
| labels: | | ||
| org.opencontainers.image.title=GitHub Actions Utils CLI | ||
| org.opencontainers.image.description=MCP server for GitHub Actions utilities | ||
| maintainer=techprimate GmbH <opensource@techprimate.com> | ||
|
|
||
| - name: Login to Docker Hub | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| username: ${{ vars.DOCKERHUB_USERNAME }} | ||
| password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
|
||
| - name: Login to GitHub Container Registry | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| registry: ghcr.io | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Build ${{ github.event_name == 'pull_request' && '(dry run)' || 'and push' }} by digest | ||
| id: build | ||
| uses: docker/build-push-action@v6 | ||
| with: | ||
| context: . | ||
| file: ./Dockerfile | ||
| platforms: ${{ matrix.platform.name }} | ||
| tags: ${{ steps.meta.outputs.tags }} | ||
| labels: ${{ steps.meta.outputs.labels }} | ||
| annotations: ${{ steps.meta.outputs.annotations }} | ||
| cache-from: type=registry,ref=ghcr.io/${{ github.repository }}:buildcache-${{ matrix.platform.tag }} | ||
| cache-to: type=registry,ref=ghcr.io/${{ github.repository }}:buildcache-${{ matrix.platform.tag }},mode=max | ||
| outputs: type=image,push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' }} | ||
| env: | ||
| DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index | ||
|
|
||
| - name: Export digest | ||
| if: github.event_name != 'pull_request' | ||
| run: | | ||
| set -e | ||
| mkdir -p /tmp/digests | ||
| digest="${{ steps.build.outputs.digest }}" | ||
| touch "/tmp/digests/${digest#sha256:}" | ||
| ls -la /tmp/digests | ||
|
|
||
| - name: Upload digest | ||
| if: github.event_name != 'pull_request' | ||
| uses: actions/upload-artifact@v5 | ||
| with: | ||
| name: cli-docker-digests-${{ matrix.platform.tag }} | ||
| path: /tmp/digests/* | ||
| if-no-files-found: error | ||
| retention-days: 1 | ||
|
|
||
| merge: | ||
| name: Create Manifest List | ||
| runs-on: ubuntu-latest | ||
| needs: build | ||
| if: github.event_name != 'pull_request' | ||
| permissions: | ||
| contents: read | ||
| packages: write | ||
| id-token: write | ||
| timeout-minutes: 10 | ||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }}-merge | ||
| cancel-in-progress: true | ||
| steps: | ||
| - name: Download digests | ||
| uses: actions/download-artifact@v6 | ||
| with: | ||
| path: /tmp/digests | ||
| pattern: cli-docker-digests-* | ||
| merge-multiple: true | ||
|
|
||
| - name: List digests | ||
| run: ls -la /tmp/digests | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
|
|
||
| - name: Create Docker Metadata | ||
| id: meta | ||
| uses: docker/metadata-action@v5 | ||
| with: | ||
| images: | | ||
| docker.io/${{ github.repository }} | ||
| ghcr.io/${{ github.repository }} | ||
| tags: | | ||
| type=raw,value=${{ inputs.tag_name }} | ||
| type=raw,value=latest,enable=${{ inputs.is_prerelease == 'true' }} | ||
| type=semver,pattern={{version}},value=${{ inputs.tag_name }},enable=${{ inputs.is_prerelease == 'false' }} | ||
| type=semver,pattern={{major}}.{{minor}},value=${{ inputs.tag_name }},enable=${{ inputs.is_prerelease == 'false' }} | ||
philprime marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| type=semver,pattern={{major}},value=${{ inputs.tag_name }},enable=${{ inputs.is_prerelease == 'false' }} | ||
|
|
||
| - name: Login to Docker Hub | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| username: ${{ vars.DOCKERHUB_USERNAME }} | ||
| password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
|
||
| - name: Login to GitHub Container Registry | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| registry: ghcr.io | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Create manifest list and push | ||
| working-directory: /tmp/digests | ||
| run: | | ||
| # Extract all tags | ||
| image_tags=$(printf '%s' "$DOCKER_METADATA_OUTPUT_JSON" | jq -cr '.tags | map("-t " + .) | join(" ")') | ||
| echo "Creating manifest list with tags: $image_tags" | ||
|
|
||
| # Extract unique image names (without tags) to build digest references | ||
| image_names=$(printf '%s' "$DOCKER_METADATA_OUTPUT_JSON" | jq -cr '.tags | map(split(":")[0]) | unique | join(" ")') | ||
| echo "Image names: $image_names" | ||
|
|
||
| # Build digest references for all images | ||
| digest_refs="" | ||
| for image_name in $image_names; do | ||
| for digest_file in *; do | ||
| digest_refs="$digest_refs ${image_name}@sha256:${digest_file}" | ||
| done | ||
| done | ||
| echo "Digest references: $digest_refs" | ||
|
|
||
| echo "Creating manifest using buildx..." | ||
| docker buildx imagetools create $image_tags $digest_refs | ||
|
|
||
| # Inspect the first tag for verification | ||
| first_tag=$(printf '%s' "$DOCKER_METADATA_OUTPUT_JSON" | jq -cr '.tags[0]') | ||
| docker buildx imagetools inspect "$first_tag" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.