Skip to content

Commit

Permalink
Merge pull request #5 from BlazeIsClone/develop
Browse files Browse the repository at this point in the history
cicd: refactor testing & image pipelines
  • Loading branch information
BlazeIsClone authored Sep 16, 2024
2 parents f5d6916 + 077e1fa commit 1d074fb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
36 changes: 21 additions & 15 deletions .github/workflows/image-repository.yml
Original file line number Diff line number Diff line change
@@ -1,50 +1,56 @@
name: Build & Push Images

on:
workflow_run:
workflows: [Run Tests]
types:
- completed
push:
branches: ["main"]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
prepare:
name: "Prepare 🚧"
test:
runs-on: ubuntu-latest

if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- run: echo 'The triggering workflow passed'
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.22.1"

- name: Build
run: go build -v ./...

- name: Test
run: go test -v ./...

build-and-push-image:
name: "Build & Push πŸ“¦"
needs: [prepare]
name: "Build & Push"
needs: [test]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository πŸ“­
- name: Checkout repository
uses: actions/checkout@v3

- name: Log in to the Container registry πŸ”“
- name: Log in to the Container registry
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker πŸ“‚
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/[email protected]
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image πŸš€
- name: Build and push Docker image
uses: docker/[email protected]
with:
context: .
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: Run Tests

on:
push:
pull_request:
branches: ["main"]

jobs:
build:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down

0 comments on commit 1d074fb

Please sign in to comment.