Skip to content

Create CI system for ChAI #2

Create CI system for ChAI

Create CI system for ChAI #2

name: build-CI-container
env:
REGISTRY: ghcr.io
# NOTE: IMAGE_NAME must be lowercase
IMAGE_NAME: chai-github-ci
# NOTE: if this filename changes, also update in the on.paths section below
DOCKERFILE: .github/docker/Dockerfile
on:
push:
branches: [ main ]
# This limits the action so it only builds when this file changes
paths:
# unfortunately we can't use ${{env.DOCKERFILE}} here
# see https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability
- .github/docker/Dockerfile
# also trigger on changes to this workflow file itself
- .github/workflows/build-CI-container.yml
pull_request:
paths:
# same as for pushes above
- .github/docker/Dockerfile
- .github/workflows/build-CI-container.yml
# Adds a "manual run" option in the GH UI
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Login to GitHub Container Registry
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build Docker Image
uses: docker/[email protected]
with:
file: ${{ env.DOCKERFILE }}
# example: ghcr.io/chapel-lang/chapel-github-ci:latest
tags: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:latest
- name: Push Docker Image if on main
uses: docker/[email protected]
with:
file: ${{ env.DOCKERFILE }}
push: true
tags: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:latest