diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 5a859d0..5404272 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -56,9 +56,9 @@ jobs: uses: docker/build-push-action@v5 with: context: . - file: no-entrypoint.Dockerfile + file: ci.Dockerfile push: true platforms: linux/amd64,linux/arm64 - tags: ${{ steps.meta.outputs.tags }}-no-entrypoint + tags: ${{ steps.meta.outputs.tags }}-ci labels: ${{ steps.meta.outputs.labels }} build-args: "VERSION=${GITHUB_REF##*/}" diff --git a/README.md b/README.md index 6b63240..01dcd63 100644 --- a/README.md +++ b/README.md @@ -1,28 +1,44 @@ # @adguard/github-actions-runner ## Description -`@adguard/github-actions-runner` is a versatile command-line interface (CLI) tool designed to facilitate the automation of GitHub Actions, particularly geared towards simplifying repository mirroring, command execution, and artifact management in a seamless manner. It leverages GitHub's robust API to offer a streamlined approach to running and managing GitHub workflows, making it an essential tool for developers looking to integrate GitHub Actions more deeply into their development and deployment processes. + +Imagine that you have a CI pipeline, and you want to run a part of your tasks on GitHub +Actions. + +`@adguard/github-actions-runner` is a versatile command-line interface (CLI) tool designed to facilitate the +automation of GitHub Actions. It is particularly geared towards simplifying repository mirroring, command execution, and +artifact management. By leveraging GitHub's robust API, it provides a streamlined approach to running and managing +GitHub workflows, making it an essential tool for developers who need to integrate GitHub Actions more deeply into their +development and deployment processes. + +Whether you're a DevOps engineer or a software developer, this tool allows you to interact with GitHub Actions in a way +that enhances productivity and offers greater flexibility. The CLI is designed with various use cases in mind, from +automating workflows to managing artifacts, enabling developers to focus more on writing code and less on managing +pipelines. ## Installation -To get started with using `@adguard/github-actions-runner`, ensure that Node.js is installed on your system, and then you can install the package via: -pnpm: +To get started with using `@adguard/github-actions-runner`, ensure that Node.js is installed on your system, then +install the package with one of the following methods: + +- Using pnpm: ```bash pnpm install @adguard/github-actions-runner ``` -npm: +- Using npm: ```bash npm install @adguard/github-actions-runner ``` -or yarn: +- Using yarn: ```bash yarn add @adguard/github-actions-runner ``` ## Usage -The CLI tool can be used to trigger and manage GitHub Actions with the following command format: + +The CLI tool can trigger and manage GitHub Actions with the following command format: ```bash Usage: github-actions-runner run-action [options] @@ -44,12 +60,14 @@ Options: ``` ### Note: + Ensure that you have a valid `GITHUB_TOKEN` set in your environment variables for authentication. ### Example: + To run a GitHub Action workflow with the specified configuration: -``` +```bash github-actions-runner run-action \ --repo "AdguardTeam/GithubActionsRunner" \ --workflow "build.yml" \ @@ -61,18 +79,24 @@ github-actions-runner run-action \ --verbose ``` -### Docker: -This CLI tool is also available as a Docker image, which can be used to run the tool in a containerized environment. -The Docker image can be pulled from the GitHub Container Registry: +### Docker + +This CLI tool is available as a Docker image, enabling its use in containerized environments. There are two Docker +images available, each serving different use cases. + +#### Standard Docker Image + +The standard Docker image includes an `ENTRYPOINT` to simplify command execution. You can pull it from the GitHub +Container Registry and run it like this: ```bash docker pull ghcr.io/adguard/github-actions-runner:latest ``` -To run the Docker image, you can use the following command: +To run the image, use the following command: ```bash -docker run --rm -it ghcr.io/adguardteam/githubactionsrunner:latest run-action \ +docker run --rm -it ghcr.io/adguard/github-actions-runner:latest run-action \ --repo "AdguardTeam/GithubActionsRunner" \ --workflow "build.yml" \ --branch "master" \ @@ -83,5 +107,25 @@ docker run --rm -it ghcr.io/adguardteam/githubactionsrunner:latest run-action \ --verbose ``` +#### Docker Image without ENTRYPOINT + +This alternative Docker image doesn't set an `ENTRYPOINT`, providing more flexibility for advanced use cases. Pull it +from the GitHub Container Registry and run it like this: + +```bash +docker pull ghcr.io/adguard/github-actions-runner:latest-ci +``` + +To run the image, you need to specify the command manually: + +```bash +docker run --rm -it ghcr.io/adguard/github-actions-runner:latest-ci /bin/sh +``` + +In this mode, you can execute commands manually inside the container or create custom entry points for specific +workflows. + ## Contributing -Contributions to extend the functionality or improve the tool are welcome. Please refer to the project's repository on GitHub to submit issues or pull requests. + +Contributions to extend the functionality or improve the tool are welcome. Please refer to the project's repository on +GitHub to submit issues or pull requests. diff --git a/bamboo-specs/build.yaml b/bamboo-specs/build.yaml index 74fd526..1de5437 100644 --- a/bamboo-specs/build.yaml +++ b/bamboo-specs/build.yaml @@ -32,7 +32,7 @@ Build: set -x set -e - # Fix mixed logs + # Combine stderr and stdout for consistent log output exec 2>&1 ls -laht @@ -46,7 +46,12 @@ Build: branch="${bamboo_planRepository_branchName}" revision="${bamboo_planRepository_revision}" - GITHUB_TOKEN=${bamboo.githubActionsRunnerPassword} node dist/bin/index.js run-action --repo AdguardTeam/GithubActionsRunner --branch "$branch" --rev "$revision" --workflow build.yml --artifacts-path . + GITHUB_TOKEN=${bamboo.githubActionsRunnerPassword} node dist/bin/index.js run-action \ + --repo AdguardTeam/GithubActionsRunner \ + --branch "$branch" \ + --rev "$revision" \ + --workflow build.yml \ + --artifacts-path . - inject-variables: file: build.txt scope: RESULT @@ -64,7 +69,7 @@ Build: set -x set -e - # Fix mixed logs + # Combine stderr and stdout for consistent log output exec 2>&1 ls -laht diff --git a/bamboo-specs/deploy.yaml b/bamboo-specs/deploy.yaml index eb0cf24..50d89d5 100644 --- a/bamboo-specs/deploy.yaml +++ b/bamboo-specs/deploy.yaml @@ -24,7 +24,7 @@ npmjs: set -e set -x - # Fix mixed logs + # Combine stderr and stdout for consistent log output exec 2>&1 ls -laht diff --git a/bamboo-specs/example.yaml b/bamboo-specs/example.yaml index 5c89d4e..242878d 100644 --- a/bamboo-specs/example.yaml +++ b/bamboo-specs/example.yaml @@ -5,6 +5,7 @@ plan: key: GHACTIONSRUNEXAMPLE name: github-actions-runner - example variables: + # TODO replace to :latest-ci dockerNode: ghcr.io/adguardteam/githubactionsrunner:latest-no-entrypoint stages: @@ -32,7 +33,7 @@ Test: set -x set -e - # Fix mixed logs + # Combine stderr and stdout for consistent log output exec 2>&1 ls -laht @@ -40,23 +41,12 @@ Test: branch="${bamboo_planRepository_branchName}" revision="${bamboo_planRepository_revision}" - GITHUB_TOKEN=${bamboo.githubActionsRunnerPassword} github-actions-runner run-action --repo AdguardTeam/GithubActionsRunner --branch "$branch" --rev "$revision" --workflow example.yml --artifacts-path . - final-tasks: - - script: - interpreter: SHELL - scripts: - - |- - set -x - set -e - - # Fix mixed logs - exec 2>&1 - - ls -laht - - echo "Size before cleanup:" && du -h | tail -n 1 - rm -rf node_modules - echo "Size after cleanup:" && du -h | tail -n 1 + GITHUB_TOKEN=${bamboo.githubActionsRunnerPassword} github-actions-runner run-action \ + --repo AdguardTeam/GithubActionsRunner \ + --branch "$branch" \ + --rev "$revision" \ + --workflow example.yml \ + --artifacts-path . artifacts: - name: github-actions-runner.tgz pattern: github-actions-runner.tgz diff --git a/bamboo-specs/increment.yaml b/bamboo-specs/increment.yaml index 1fe279f..e1266b1 100644 --- a/bamboo-specs/increment.yaml +++ b/bamboo-specs/increment.yaml @@ -32,7 +32,7 @@ Increment: set -x set -e - # Fix mixed logs + # Combine stderr and stdout for consistent log output exec 2>&1 ls -alt diff --git a/bamboo-specs/tests.yaml b/bamboo-specs/tests.yaml index 575f59b..4b60d43 100644 --- a/bamboo-specs/tests.yaml +++ b/bamboo-specs/tests.yaml @@ -32,7 +32,7 @@ Test: set -x set -e - # Fix mixed logs + # Combine stderr and stdout for consistent log output exec 2>&1 ls -laht @@ -46,7 +46,11 @@ Test: branch="${bamboo_planRepository_branchName}" revision="${bamboo_planRepository_revision}" - GITHUB_TOKEN=${bamboo.githubActionsRunnerPassword} node dist/bin/index.js run-action --repo AdguardTeam/GithubActionsRunner --branch "$branch" --rev "$revision" --workflow test.yml + GITHUB_TOKEN=${bamboo.githubActionsRunnerPassword} node dist/bin/index.js run-action \ + --repo AdguardTeam/GithubActionsRunner \ + --branch "$branch" \ + --rev "$revision" \ + --workflow test.yml final-tasks: - script: interpreter: SHELL @@ -55,7 +59,7 @@ Test: set -x set -e - # Fix mixed logs + # Combine stderr and stdout for consistent log output exec 2>&1 ls -laht diff --git a/no-entrypoint.Dockerfile b/ci.Dockerfile similarity index 72% rename from no-entrypoint.Dockerfile rename to ci.Dockerfile index 8a89d76..159ea0e 100644 --- a/no-entrypoint.Dockerfile +++ b/ci.Dockerfile @@ -1,3 +1,7 @@ +# This Dockerfile is used to build the GitHub Actions Runner image used in the CI pipeline. +# It doesn't has the ENTRYPOINT instruction, so it can't be used to run the image as a container. +# The ENTRYPOINT instruction is added in the Dockerfile in the root of the project. + # Stage 1: Build environment FROM node:20.12.2-bookworm-slim AS builder