From 379e812dee7c36713c30040324b99559bd74cf36 Mon Sep 17 00:00:00 2001 From: lukemarsden Date: Fri, 26 Apr 2024 18:50:37 +0100 Subject: [PATCH] docs: initial github container registry integration guide (#7088) * docs: initial github container registry integration guide Signed-off-by: Luke Marsden * docs: fix link to main.go Signed-off-by: Luke Marsden * docs: hopefully convince linter this isn't a real go file Signed-off-by: Luke Marsden * Update docs/current_docs/integrations/snippets/ghcr-workflow.yml Co-authored-by: vikram-dagger <112123850+vikram-dagger@users.noreply.github.com> Signed-off-by: lukemarsden * Integrates examplein to GitHub Actions integ page Signed-off-by: Vikram Vaswani * rename Signed-off-by: Luke Marsden * bump tag Signed-off-by: Luke Marsden --------- Signed-off-by: Luke Marsden Signed-off-by: lukemarsden Signed-off-by: Vikram Vaswani Co-authored-by: vikram-dagger <112123850+vikram-dagger@users.noreply.github.com> Co-authored-by: Vikram Vaswani --- .../integrations/642920-github-actions.mdx | 6 ++++ .../integrations/snippets/actions-ghcr.yml | 35 +++++++++++++++++++ .../integrations/snippets/actions.yml | 5 +-- 3 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 docs/current_docs/integrations/snippets/actions-ghcr.yml diff --git a/docs/current_docs/integrations/642920-github-actions.mdx b/docs/current_docs/integrations/642920-github-actions.mdx index 20b69704c0b..f20beba0260 100644 --- a/docs/current_docs/integrations/642920-github-actions.mdx +++ b/docs/current_docs/integrations/642920-github-actions.mdx @@ -9,4 +9,10 @@ The following code sample demonstrates how to integrate Dagger with GitHub Actio ```yaml title=".github/workflows/dagger.yml" file=./snippets/actions.yml ``` +The following code sample demonstrates how to use Dagger in a GitHub Action to publish a container image to GitHub Container Registry. + +```yaml title=".github/workflows/dagger.yml" file=./snippets/actions-ghcr.yml +``` + + More information is available in the [Dagger for GitHub Action page](https://github.com/marketplace/actions/dagger-for-github). diff --git a/docs/current_docs/integrations/snippets/actions-ghcr.yml b/docs/current_docs/integrations/snippets/actions-ghcr.yml new file mode 100644 index 00000000000..6937cd4587c --- /dev/null +++ b/docs/current_docs/integrations/snippets/actions-ghcr.yml @@ -0,0 +1,35 @@ +name: dagger +on: + push: + branches: [main] + +jobs: + build-publish: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Call Dagger Function to build and publish to ghcr.io + uses: dagger/dagger-for-github@v5 + with: + version: "latest" + verb: call + # modify to use different function(s) as needed + module: github.com/daggerverse/dagger-ghcr-demo@v0.1.5 + args: build-and-push --registry=$DOCKER_REGISTRY --image-name=$DOCKER_IMAGE_NAME --username=$DOCKER_USERNAME --password=env:DOCKER_PASSWORD --build-context=github.com/daggerverse/dagger-ghcr-demo + # assumes the Dagger Cloud token is in + # a repository secret named DAGGER_CLOUD_TOKEN + # set via the GitHub UI/CLI + cloud-token: ${{ secrets.DAGGER_CLOUD_TOKEN }} + env: + DOCKER_REGISTRY: ghcr.io + DOCKER_IMAGE_NAME: ${{ github.repository }} + DOCKER_USERNAME: ${{ github.actor }} + # assumes the container registry password is in + # a repository secret named REGISTRY_PASSWORD + # set via the GitHub UI/CL + DOCKER_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }} diff --git a/docs/current_docs/integrations/snippets/actions.yml b/docs/current_docs/integrations/snippets/actions.yml index 1bf3bdde7bf..cf3d80dd4db 100644 --- a/docs/current_docs/integrations/snippets/actions.yml +++ b/docs/current_docs/integrations/snippets/actions.yml @@ -8,12 +8,13 @@ jobs: name: build runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v4 - name: Call Dagger Function uses: dagger/dagger-for-github@v5 with: - version: "0.10.2" + version: "latest" verb: call # assumes a Go project # modify to use different function(s) as needed