Skip to content

Commit

Permalink
chore: add build ci
Browse files Browse the repository at this point in the history
  • Loading branch information
uhobeike committed Jul 14, 2024
1 parent 2e7f199 commit 13053ac
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 16 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/build-docker-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Build

on:
workflow_dispatch:
schedule:
- cron: '0 9 * * *'
push:
branches:
- main
paths-ignore:
- '**/LICENSE'
- '**/*.md'
pull_request:
paths-ignore:
- '**/LICENSE'
- '**/*.md'

env:
DOCKER-CONTEXT: ./
DOCKER-FILE: ./.github/Dockerfile
DOCKER-IMAGE: trainee
DOCKER-TAG: humble

jobs:
docker:
name: Build Docker Image
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker image tag
run: echo "DOCKER_IMAGE_TAG=ghcr.io/$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')/${{ env.DOCKER-IMAGE }}:${{ env.DOCKER-TAG }}" >> $GITHUB_ENV

- name: Build and push
uses: docker/build-push-action@v3
with:
context: ${{ env.DOCKER-CONTEXT }}
file: ${{ env.DOCKER-FILE }}
tags: ${{ env.DOCKER_IMAGE_TAG }}
build-args: USERNAME=runner
no-cache: true
push: false
30 changes: 14 additions & 16 deletions .github/workflows/push-docker-image.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
name: Docker
name: Push

on:
workflow_dispatch:
schedule:
- cron: '0 9 * * *'
push:
branches:
- main
paths-ignore:
- '**/LICENSE'
- '**/*.md'
pull_request:
paths-ignore:
- '**/LICENSE'
- '**/*.md'
workflow_run:
workflows: ["Build"]
types:
- completed

env:
DOCKER-CONTEXT: ./
DOCKER-FILE: ./Dockerfile
DOCKER-FILE: ./.github/Dockerfile
DOCKER-IMAGE: trainee
DOCKER-TAG: humble

jobs:
docker:
name: Build & Push Docker Image
name: Build Docker Image
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'main' }}

steps:
- uses: actions/checkout@v3
Expand All @@ -37,12 +32,15 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker image tag
run: echo "DOCKER_IMAGE_TAG=ghcr.io/$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')/${{ env.DOCKER-IMAGE }}:${{ env.DOCKER-TAG }}" >> $GITHUB_ENV

- name: Build and push
uses: docker/build-push-action@v3
with:
context: ${{ env.DOCKER-CONTEXT }}
file: ${{ env.DOCKER-FILE }}
tags: ghcr.io/${{ github.repository_owner }}/trainee:humble
tags: ${{ env.DOCKER_IMAGE_TAG }}
build-args: USERNAME=runner
no-cache: true
push: true

0 comments on commit 13053ac

Please sign in to comment.