kubesphere / devops-agent

Agents for Kubesphere DevOps
Apache License 2.0
61 stars 73 forks source link

Create composite GitHub action to simplify workflow configuration #59

Closed JohnNiang closed 2 years ago

JohnNiang commented 2 years ago

What this PR dose?

Create composite GitHub action to simplify workflow configuration.

Below are input variables' details of composite GitHub action:

  context:
    description: Build context for docker.
    required: true
  dockerfile:
    description: Dockerfile location.
    required: true
  image-name:
    description: Docker image name.
    required: true
  tag-suffix:
    description: Suffix of tag name.
    required: true
    default: ""
  platforms:
    description: Builder node platforms available (comma separated).
    required: true
    default: "linux/amd64"
  build-args:
    description: List of build-time variables.
    required: false
    default: ""
  docker-registry:
    description: Docker registry.
    required: false
    default: docker.io
  docker-namespace:
    description: Docker namespace.
    required: false
    default: ""
  docker-password:
    description: Password of current docker namespace in docker registry.
    required: false
    default: ""
  ghcr-token:
    description: Token of current GitHub account in GitHub container registry.
    required: false
    default: ""

Example of using composite GitHub action:

  BuildBase:
    runs-on: ubuntu-20.04
    steps:
      - uses: actions/checkout@v2
      - name: Build base agent
        uses: ./.github/actions/build
        with:
          context: base
          dockerfile: base/Dockerfile
          image-name: builder-base
          platforms: linux/amd64,linux/arm64
          docker-namespace: ${{ secrets.DOCKER_HUB_USER }}
          docker-password: ${{ secrets.DOCKER_HUB_SECRETS }}
          ghcr-token: ${{ secrets.GHCR_TOKEN }}

For the result, please see:

Why do we need it?

At present, our GitHub workflow configuration is highly repetitive and difficult to manage. If we want to add a new agent into this repo, we need to do some error-prone and duplicate works.

Which issue dose this PR fix?

Fix #53

/kind feature /cc @kubesphere/sig-devops

JohnNiang commented 2 years ago

/ping @kubesphere/sig-devops

JohnNiang commented 2 years ago

/ping @kubesphere/sig-devops

ks-ci-bot commented 2 years ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JohnNiang, LinuxSuRen

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[OWNERS](https://github.com/kubesphere/devops-agent/blob/master/OWNERS)~~ [LinuxSuRen] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment