generated from EVerest/everest-template
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move reusable workflow and everest-clang-format from everest-utils to…
… everest-ci (#16) * Add reusable worklfow deploy-single-docker-image Signed-off-by: Andreas Heinrich <[email protected]> * move reusable workflow Signed-off-by: Andreas Heinrich <[email protected]> * Rename deploy build-kit workflow Signed-off-by: Andreas Heinrich <[email protected]> * Add everest-clang-format image Signed-off-by: Andreas Heinrich <[email protected]> * Pin version of docker image Signed-off-by: Andreas Heinrich <[email protected]> --------- Signed-off-by: Andreas Heinrich <[email protected]>
- Loading branch information
Showing
6 changed files
with
601 additions
and
4 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Build and push docker images | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
force_rebuild: | ||
description: 'Force rebuild of all images' | ||
default: false | ||
type: boolean | ||
push: | ||
branches: | ||
- '**' | ||
tags: | ||
- 'v*' | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
|
||
jobs: | ||
build-and-push-all-images: | ||
name: Build and push all docker images | ||
strategy: | ||
matrix: | ||
image_name: [everest-clang-format] | ||
uses: everest/everest-ci/.github/workflows/[email protected] | ||
with: | ||
force_rebuild: ${{ inputs.force_rebuild || (github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/' )) || false }} | ||
image_name: ${{ matrix.image_name }} | ||
docker_directory: docker/images/ | ||
docker_registry: ghcr.io | ||
github_ref_before: ${{ github.event.before }} | ||
github_ref_after: ${{ github.event.after }} | ||
secrets: | ||
SA_GITHUB_PAT: ${{ secrets.SA_GITHUB_PAT }} | ||
SA_GITHUB_USERNAME: ${{ secrets.SA_GITHUB_USERNAME }} |
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 |
---|---|---|
@@ -0,0 +1,113 @@ | ||
name: Build and push single docker image | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
image_name: | ||
description: 'Name of the image to build and push' | ||
required: true | ||
type: string | ||
docker_directory: | ||
description: 'Directory containing the docker directory' | ||
required: true | ||
type: string | ||
default: docker/ | ||
docker_registry: | ||
description: 'Docker registry to push to' | ||
required: true | ||
default: 'ghcr.io' | ||
type: string | ||
github_ref_before: | ||
description: 'Github ref before the change' | ||
required: true | ||
type: string | ||
github_ref_after: | ||
description: 'Github ref after the change' | ||
required: true | ||
type: string | ||
force_rebuild: | ||
description: 'Forces rebuild of docker image, even if no changes are detected' | ||
default: false | ||
type: boolean | ||
secrets: | ||
SA_GITHUB_PAT: | ||
description: 'Github PAT with access to the repository' | ||
required: true | ||
SA_GITHUB_USERNAME: | ||
description: 'Github username' | ||
required: true | ||
|
||
jobs: | ||
check: | ||
name: Check for changes | ||
outputs: | ||
changed_files: ${{ steps.changed-files.outputs.changed_files }} | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Checkout Dockerfile | ||
uses: actions/checkout@v3 | ||
with: | ||
repository: ${{ github.repository }} | ||
path: source | ||
ref: ${{ inputs.github_ref_after }} | ||
token: ${{secrets.SA_GITHUB_PAT}} | ||
fetch-depth: 0 | ||
- name: Get changed files | ||
id: changed-files | ||
run: | | ||
echo "changed_files=$(git diff --name-only ${{ inputs.github_ref_before }} ${{ inputs.github_ref_after }} | grep "^${{inputs.docker_directory}}/${{inputs.image_name}}" | wc -l)" >> $GITHUB_OUTPUT | ||
working-directory: source | ||
|
||
build-and-push: | ||
name: Build and push | ||
needs: check | ||
if: ${{ needs.check.outputs.changed_files > 0 || inputs.force_rebuild }} | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Checkout Dockerfile | ||
uses: actions/checkout@v3 | ||
with: | ||
repository: ${{ github.repository }} | ||
path: source | ||
ref: ${{github.ref}} | ||
token: ${{secrets.SA_GITHUB_PAT}} | ||
fetch-depth: 0 | ||
- name: Get context / Path of Dockerfile | ||
id: get-context | ||
run: | | ||
if [ -f source/${{ inputs.docker_directory }}/${{ inputs.image_name }}/Dockerfile ]; then | ||
echo "::set-output name=path::source/${{ inputs.docker_directory }}/${{ inputs.image_name }}/" | ||
elif [ -f source/${{ inputs.docker_directory }}/${{ inputs.image_name }}/.devcontainer/Dockerfile ]; then | ||
echo "::set-output name=path::source/${{ inputs.docker_directory }}/${{ inputs.image_name }}/.devcontainer/" | ||
else | ||
echo "No Dockerfile found for image ${{ inputs.image_name }}!" | ||
exit 1 | ||
fi | ||
- name: Extract metadata | ||
id: meta | ||
uses: docker/metadata-action@v3 | ||
with: | ||
images: ${{ inputs.docker_registry }}/${{ github.repository_owner }}/${{ inputs.image_name }} | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
with: | ||
image: tonistiigi/binfmt:latest | ||
platforms: all | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- name: Login to DockerHub | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ${{ inputs.docker_registry }} | ||
username: ${{ secrets.SA_GITHUB_USERNAME }} | ||
password: ${{ secrets.SA_GITHUB_PAT }} | ||
- name: Build and push | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: ${{ steps.get-context.outputs.path }} | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
platforms: linux/amd64,linux/arm64,linux/arm/v7 | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
ARG BASE_IMAGE=debian:12 | ||
FROM ${BASE_IMAGE} | ||
|
||
RUN apt update && apt upgrade -y | ||
RUN apt update && \ | ||
apt install -y \ | ||
clang-format-15=1:15.0.6* | ||
RUN ln -s /usr/bin/clang-format-15 /usr/bin/clang-format | ||
|
||
RUN apt install -y \ | ||
python-is-python3 | ||
|
||
COPY run-clang-format.py /usr/bin/run-clang-format | ||
|
||
ENTRYPOINT ["/usr/bin/run-clang-format"] |
Oops, something went wrong.