diff --git a/LICENSE b/LICENSE index d645695..261eeb9 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,3 @@ - Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ diff --git a/README.md b/README.md index 2a22ce0..ebc3e9e 100644 --- a/README.md +++ b/README.md @@ -1,129 +1,25 @@ -![Dagger](.github/dagger.png) +# dagger-for-github -[![GitHub release](https://img.shields.io/github/release/dagger/dagger-for-github.svg?style=flat-square)](https://github.com/dagger/dagger-for-github/releases/latest) -[![GitHub marketplace](https://img.shields.io/badge/marketplace-dagger--action-blue?logo=github&style=flat-square)](https://github.com/marketplace/actions/dagger-for-github) -[![Test workflow](https://img.shields.io/github/workflow/status/dagger/dagger-for-github/test?label=test&logo=github&style=flat-square)](https://github.com/dagger/dagger-for-github/actions?workflow=test) -[![Codecov](https://img.shields.io/codecov/c/github/dagger/dagger-for-github?logo=codecov&style=flat-square)](https://codecov.io/gh/dagger/dagger-for-github) - -## About - -GitHub Action for [Dagger](https://dagger.io), a programmable deployment system. - -![Screenshot](.github/dagger-for-github.png) - -___ - -* [Usage](#usage) - * [Basic](#basic) - * [Install Only](#install-only) - * [Multiple commands](#multiple-commands) -* [Customizing](#customizing) - * [inputs](#inputs) -* [License](#license) - -## Usage - -### Basic +Github action to run Dagger ```yaml -name: dagger - -on: - push: - branches: - - main - -jobs: - deploy: - runs-on: ubuntu-latest - steps: - - - name: Checkout - uses: actions/checkout@v3 - - - name: Dagger - uses: dagger/dagger-for-github@v4 - with: - cmds: do test +- name: Dagger + uses: dagger/dagger-for-github@v5 + with: + module: github.com/kpenfound/greetings-api/ci + args: ci --commit $GITHUB_SHA + cloud-token: ${{ secrets.DAGGER_CLOUD_TOKEN }} ``` -### Install Only +or with more options: ```yaml -steps: - - - name: Install Dagger - uses: dagger/dagger-for-github@v4 - with: - install-only: true - - - name: Show Dagger version - run: dagger-cue version +- name: Dagger + uses: dagger/dagger-for-github@v5 + with: + module: github.com/kpenfound/greetings-api/ci + args: ci --commit $GITHUB_SHA + cloud-token: ${{ secrets.DAGGER_CLOUD_TOKEN }} + version: "0.9.3" + verb: call ``` - -### Install Only and `--with` - -```yaml -steps: - - - name: Install Dagger - uses: dagger/dagger-for-github@v4 - with: - install-only: true - - - - name: Build a subdir example - run: | - dagger-cue do build --log-format plain -with 'actions:build:subdir: ${{env.SUBDIR}}' -``` - -### Multiple commands - -```yaml -steps: - - - name: Dagger - uses: dagger/dagger-for-github@v4 - with: - cmds: | - project update - do test -``` - -## Customizing - -### inputs - -Following inputs can be used as `step.with` keys - -> `List` type is a newline-delimited string -> ```yaml -> cmds: | -> project update -> do test -> ``` - -| Name | Type | Default | Description | -|----------------|--------|---------|----------------------------------------------------------------------------------------| -| `version` | String | `0.2.232` | Dagger version (e.g., `0.2.232`, `latest`, `https://github.com/dagger/dagger.git#main`) | -| `cmds` | List | | List of Dagger commands | -| `workdir` | String | `.` | Working directory (below repository root) | -| `install-only` | Bool | `false` | Just install Dagger | -| `cleanup` | Bool | `true` | Cleanup Dagger home folder at the end of a job | - -## Development - -```shell -# format code and build javascript artifacts -docker buildx bake pre-checkin - -# validate all code has correctly formatted and built -docker buildx bake validate - -# run tests -docker buildx bake test -``` - -## License - -Apache-2.0 License. See `LICENSE` for more details. diff --git a/action.yml b/action.yml index 9e90c3b..1c52c8f 100644 --- a/action.yml +++ b/action.yml @@ -1,36 +1,40 @@ name: 'Dagger for GitHub' -description: 'GitHub Action for Dagger, a programmable deployment system' -author: 'dagger' -branding: - color: 'green' - icon: 'package' - +description: 'Run dagger commands in Github Actions' inputs: version: - description: 'Dagger CUE version' - default: '0.2.232' + description: 'Dagger Version' required: false - args: - description: 'Arguments to pass to Dagger' + default: '0.9.3' + dagger-flags: + description: 'Dagger CLI Flags' required: false - deprecationMessage: 'Use cmds input instead' - cmds: - description: 'List of Dagger commands' + default: '-s' + verb: + description: 'CLI verb (call, download, up, functions, shell, query)' required: false - workdir: - description: 'Working directory (below repository root)' - default: '.' + default: 'call' + cloud-token: + description: 'Dagger Cloud Token' required: false - install-only: - description: 'Just install Dagger' - default: 'false' + default: '' + module: + description: 'Dagger module to call. Local or Git' required: false - cleanup: - description: 'Cleanup Dagger home folder at the end of a job' - default: 'true' + default: '.' + args: + description: 'Arguments to pass to CLI' required: false - + default: '' runs: - using: 'node16' - main: 'dist/index.js' - post: 'dist/index.js' + using: "composite" + steps: + - run: cd /usr/local && { curl -L https://dl.dagger.io/dagger/install.sh | DAGGER_VERSION=${{ inputs.version }} sh; cd -; } + shell: bash + - run: if ! [ -d ./.git ]; then git clone -b ${GITHUB_REF_NAME} --no-checkout https://github.com/${GITHUB_REPOSITORY} .; fi + shell: bash + - run: DAGGER_CLOUD_TOKEN=${{ inputs.cloud-token }} /usr/local/bin/dagger ${{ inputs.dagger-flags }} ${{ inputs.verb }} -m ${{ inputs.module }} ${{ inputs.args }} + shell: bash + - run: docker stop -t 300 $(docker ps --filter name="dagger-engine-*" -q) + shell: bash + if: ${{ always() }} +