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