-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4d7cadc
commit 8cd30a2
Showing
6 changed files
with
55 additions
and
418 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,75 @@ | ||
--- | ||
name: Build a new image and then upload the image, tags and manifests to GitHub artifacts | ||
name: Build Docker image | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- v* | ||
workflow_dispatch: | ||
|
||
env: | ||
OWNER: ${{ github.repository_owner }} | ||
FORCE_COLOR: 1 | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
image: | ||
description: Image name | ||
required: true | ||
type: string | ||
architecture: | ||
description: Image architecture, e.g. amd64, arm64 | ||
required: true | ||
type: string | ||
runsOn: | ||
description: GitHub Actions Runner image | ||
required: true | ||
type: string | ||
# https://docs.github.com/en/actions/using-jobs/using-concurrency | ||
concurrency: | ||
# only cancel in-progress jobs or runs for the current workflow - matches against branch & tags | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
build-test-upload: | ||
runs-on: ${{ inputs.runsOn }} | ||
runs-on: ubuntu-latest | ||
continue-on-error: true | ||
|
||
steps: | ||
- name: Checkout Repo ⚡️ | ||
uses: actions/checkout@v4 | ||
- name: Create dev environment 📦 | ||
uses: ./.github/actions/create-dev-env | ||
with: | ||
architecture: ${{ inputs.architecture }} | ||
|
||
# Self-hosted runners share a state (whole VM) between runs | ||
# Also, they might have running or stopped containers, | ||
# which are not cleaned up by `docker system prun` | ||
- name: Reset docker state and cleanup artifacts 🗑️ | ||
if: ${{ startsWith(inputs.runsOn, 'ubuntu') }} | ||
run: | | ||
docker kill $(docker ps --quiet) || true | ||
docker rm $(docker ps --all --quiet) || true | ||
docker system prune --all --force | ||
rm -rf /tmp/aiidalab/ | ||
shell: bash | ||
- name: Login to Container Registry 🔑 | ||
uses: docker/login-action@v2 | ||
if: ${{ !github.event.pull_request.head.repo.fork }} | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build image 🛠 | ||
working-directory: docker | ||
run: docker buildx bake --set qe.platform=linux/${{ inputs.architecture }} -f docker-bake.hcl -f build.json --load | ||
env: | ||
# Use buildx | ||
DOCKER_BUILDKIT: 1 | ||
# Full logs for CI build | ||
BUILDKIT_PROGRESS: plain | ||
shell: bash | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Run tests ✅ | ||
uses: ./.github/actions/integration-tests | ||
- name: Docker meta 📝 | ||
if: ${{ !github.event.pull_request.head.repo.fork }} | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
architecture: ${{ inputs.architecture }} | ||
runsOn: ${{ inputs.runsOn }} | ||
images: | | ||
name=ghcr.io/{{ github.repository_owner }}/qe | ||
tags: | | ||
type=edge,enable={{is_default_branch}} | ||
type=ref,event=pr | ||
type=match,pattern=v(\d{2}\.\d{2}.\d+.*),group=1 | ||
type=raw,value={{tag}},enable=${{ startsWith(github.ref, 'refs/tags/v') }} | ||
- name: Save image as a tar for later use 💾 | ||
run: | | ||
mkdir -p /tmp/aiidalab/ | ||
docker save ${{ env.OWNER }}/${{ inputs.image }} -o /tmp/aiidalab/${{ inputs.image }}-${{ inputs.architecture }}.tar | ||
shell: bash | ||
if: always() | ||
- name: Build and load to Docker | ||
id: build-upload | ||
uses: docker/build-push-action@v5 | ||
with: | ||
tags: ${{ steps.meta.outputs.tags }} | ||
load: ${{ github.event.pull_request.head.repo.fork }} | ||
push: ${{ ! github.event.pull_request.head.repo.fork }} | ||
context: . | ||
platforms: linux/amd64 | ||
cache-to: | | ||
type=gha,scope=${{ github.workflow }},mode=min | ||
cache-from: | | ||
type=gha,scope=${{ github.workflow }} | ||
- name: Upload image as artifact 💾 | ||
uses: actions/upload-artifact@v4 | ||
- name: Set Up Python 🐍 | ||
uses: actions/setup-python@v5 | ||
with: | ||
name: ${{ inputs.image }}-${{ inputs.architecture }} | ||
path: /tmp/aiidalab/${{ inputs.image }}-${{ inputs.architecture }}.tar | ||
retention-days: 3 | ||
if: always() | ||
python-version: 3.11 | ||
|
||
- name: Install Dev Dependencies 📦 | ||
run: pip install -r docker/requirements-dev.txt |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.