Skip to content

Commit

Permalink
test(ci): refactor workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
jimehk committed Apr 11, 2024
1 parent 2cd0330 commit 55dc2ec
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 30 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: Build
on:
workflow_call:
inputs:
image:
description: "Output image to publish"
type: string
default: "ghcr.io/krystal/actions-runner:latest"
runner_version:
description: "Runner version"
type: string
default: "2.315.0"
docker_compose_version:
description: "Docker compose version"
type: string
default: "2.26.1"

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v5
with:
tags: ${{ inputs.image }}
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
RUNNER_VERSION=${{ inputs.runner_version }}
DOCKER_COMPOSE_VERSION=${{ inputs.docker_compose_version }}
37 changes: 7 additions & 30 deletions .github/workflows/build.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
name: CI
on:
workflow_dispatch:
schedule:
Expand All @@ -7,21 +8,9 @@ on:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v5
with:
tags: ghcr.io/${{ github.repository }}-ci:run-${{ github.run_id }}
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
uses: ./.github/workflows/_build.yml
with:
image: ghcr.io/${{ github.repository }}-ci:run-${{ github.run_id }}

test-ruby:
needs: [build]
Expand Down Expand Up @@ -68,20 +57,8 @@ jobs:
working-directory: test/go

publish:
runs-on: ubuntu-latest
needs: [test-ruby, test-go]
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v5
with:
tags: ghcr.io/${{ github.repository }}:latest
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
uses: ./.github/workflows/_build.yml
with:
image: ghcr.io/${{ github.repository }}:latest

0 comments on commit 55dc2ec

Please sign in to comment.