Skip to content

Commit

Permalink
Merge pull request #120 from rtCamp/action/images-bake
Browse files Browse the repository at this point in the history
Automated Docker image baking with GitHub Action
  • Loading branch information
Xieyt authored Feb 29, 2024
2 parents a0a1142 + 47f9723 commit f928791
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 37 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/bake-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Publish image

on:
schedule:
- cron: '0 2 * * *'
push:
tags:
- v*

jobs:
build-and-push:
name: Build and push image
strategy:
matrix:
os: [self-hosted-arm64,ubuntu-latest]
platform: [linux/amd64, linux/arm64]
service_name: [frappe, mailhog, nginx]
exclude:
- os: ubuntu-latest
platform: linux/arm64
- os: self-hosted-arm64
platform: linux/amd64

runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up tag
id: set-tag
run: |
latest_tag=$(git describe --abbrev=0 --tags)
if [[ "${{ github.ref == 'refs/tags/v*' }}" == 'true' ]]; then
latest-tag=${GITHUB_REF/refs\/tags\//}
fi
owner=$( echo '${{ github.repository_owner }}' | tr '[:upper:]' '[:lower:]' )
echo "Checkout: $latest_tag"
git checkout "$latest_tag"
tag=$( cat "$GITHUB_WORKSPACE/Docker/images-tag.json" | jq -rc .${{ matrix.service_name }})
echo "image_name=ghcr.io/${owner}/frappe-manager-${{ matrix.service_name }}:${tag}" >> $GITHUB_ENV
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
platforms: ${{ matrix.platform }}

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ secrets.GHCR_USER }}
password: ${{ secrets.GHCR_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: Docker/${{ matrix.service_name }}/.
push: true
platforms: ${{ matrix.platform }}
tags: ${{ env.image_name }}
37 changes: 0 additions & 37 deletions .github/workflows/docker-push.yml

This file was deleted.

5 changes: 5 additions & 0 deletions Docker/images-tag.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"frappe": "v0.11.0",
"nginx": "v0.10.0",
"mailhog": "v0.8.3"
}

0 comments on commit f928791

Please sign in to comment.