Skip to content

ci: setup GitHub Actions #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions .github/workflows/pi_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: 'Parent Images: Build'

on:
workflow_dispatch:

pull_request:
types: [opened, synchronize, reopened]

permissions:
id-token: write
contents: write
actions: read

jobs:
configure-branch-name:
name: 'Configure Head Branch Name'
runs-on: ubuntu-latest
outputs:
gh_head_ref: ${{ steps.configure-branch-name.outputs.gh_head_ref }}
steps:
- name: Configure branch name
id: configure-branch-name
run: echo "gh_head_ref=$(echo "${{ github.event.pull_request.head.ref }}" | sed 's|/|-|g')" >> $GITHUB_OUTPUT

pi-build:
name: 'Parent Images: Docker Build'
runs-on: ubuntu-latest
needs: [configure-branch-name]
environment: dev
env:
PYTHON_VERSION: ${{ vars.PYTHON_VERSION }}
DEV_CONTAINER_REGISTRY: ${{ vars.DEV_CONTAINER_REGISTRY }}
DEV_LOGIN_USERNAME: ${{ secrets.DEV_LOGIN_USERNAME }}
DEV_LOGIN_PASSWORD: ${{ secrets.DEV_LOGIN_PASSWORD }}
PARENT_IMAGE_TYPE: ${{ vars.PARENT_IMAGE_TYPE }}
DOCKERFILE: ${{ vars.DOCKERFILE }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN }}
fetch-depth: 0
submodules: 'true'

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
platforms: linux/amd64,linux/arm64

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64,arm

- name: Log into DEV registry
uses: docker/login-action@v3
with:
registry: "${{ env.DEV_CONTAINER_REGISTRY }}"
username: "${{ env.DEV_LOGIN_USERNAME }}"
password: "${{ env.DEV_LOGIN_PASSWORD }}"

- name: Build & Push refinery-parent-images:${{ needs.configure-branch-name.outputs.gh_head_ref }}-${{ env.PARENT_IMAGE_TYPE }}
uses: docker/build-push-action@v5
with:
context: .
cache-from: type=registry,ref=${{ env.DEV_CONTAINER_REGISTRY }}/refinery-parent-images:${{ needs.configure-branch-name.outputs.gh_head_ref }}-${{ env.PARENT_IMAGE_TYPE }}-cache
cache-to: type=registry,ref=${{ env.DEV_CONTAINER_REGISTRY }}/refinery-parent-images:${{ needs.configure-branch-name.outputs.gh_head_ref }}-${{ env.PARENT_IMAGE_TYPE }}-cache,mode=max,image-manifest=true
platforms: linux/amd64
file: ${{ env.DOCKERFILE }}
tags: ${{ env.DEV_CONTAINER_REGISTRY }}/refinery-parent-images:${{ needs.configure-branch-name.outputs.gh_head_ref }}-${{ env.PARENT_IMAGE_TYPE }}
push: true
build-args: |
platform=linux/amd64
label=dockerfile-path=https://github.com/refinery-${{ env.PARENT_IMAGE_TYPE }}-parent-image/blob/${{ github.sha }}/${{ env.DOCKERFILE }}

- name: Build & Push refinery-parent-images:${{ needs.configure-branch-name.outputs.gh_head_ref }}-${{ env.PARENT_IMAGE_TYPE }}-arm64
uses: docker/build-push-action@v5
with:
context: .
cache-from: type=registry,ref=${{ env.DEV_CONTAINER_REGISTRY }}/refinery-parent-images:${{ needs.configure-branch-name.outputs.gh_head_ref }}-${{ env.PARENT_IMAGE_TYPE }}-arm64-cache
cache-to: type=registry,ref=${{ env.DEV_CONTAINER_REGISTRY }}/refinery-parent-images:${{ needs.configure-branch-name.outputs.gh_head_ref }}-${{ env.PARENT_IMAGE_TYPE }}-arm64-cache,mode=max,image-manifest=true
platforms: linux/arm64
file: ${{ env.DOCKERFILE }}
tags: ${{ env.DEV_CONTAINER_REGISTRY }}/refinery-parent-images:${{ needs.configure-branch-name.outputs.gh_head_ref }}-${{ env.PARENT_IMAGE_TYPE }}-arm64
push: true
build-args: |
platform=linux/arm64
label=dockerfile-path=https://github.com/refinery-${{ env.PARENT_IMAGE_TYPE }}-parent-image/blob/${{ github.sha }}/${{ env.DOCKERFILE }}

18 changes: 18 additions & 0 deletions .github/workflows/pi_merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: 'Parent Images: Parent Image Merge'

on:
workflow_dispatch:

pull_request:
types: [closed]

permissions:
id-token: write
contents: write
actions: read

jobs:
call-pi-merge-parent-image:
uses: code-kern-ai/cicd-deployment-scripts/.github/workflows/pi_merge_parent_image.yml@dev
if: ${{ github.event.pull_request.merged }}
secrets: inherit
15 changes: 15 additions & 0 deletions .github/workflows/pi_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: 'Parent Images: Release'

on:
release:
types: [prereleased]

permissions:
id-token: write
contents: read
actions: read

jobs:
call-pi-release:
uses: code-kern-ai/cicd-deployment-scripts/.github/workflows/pi_release.yml@dev
secrets: inherit
Loading