-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from KSkwarczynski/feature_CI
CI/CD to make nuwro containers
- Loading branch information
Showing
3 changed files
with
136 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
--- | ||
# Update NuWro container image registry with newest updates | ||
name: Image CD | ||
|
||
# The events that trigger the workflow | ||
on: | ||
push: | ||
branches: | ||
- master | ||
tags: | ||
- 'v*' | ||
|
||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false # KS: Prevents cancellation of remaining jobs if one fails | ||
matrix: | ||
include: | ||
- os: alma9 | ||
file: doc/docker/alma9/Dockerfile | ||
tag_latest: alma9latest | ||
|
||
name: Image CD ${{ matrix.os }} | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Log in to GitHub Container Registry | ||
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | ||
|
||
- name: Build Docker image | ||
run: | | ||
if [ "${{ github.ref_type }}" == "tag" ]; then | ||
docker build . \ | ||
--file "${{ matrix.file }}" \ | ||
--tag "ghcr.io/${{ github.repository_owner }}/nuwro:${{ matrix.os }}${{ github.ref_name }}" \ | ||
--build-arg NUWRO_VERSION="${{ github.ref_name }}" \ | ||
else | ||
docker build . \ | ||
--file "${{ matrix.file }}" \ | ||
--tag "ghcr.io/${{ github.repository_owner }}/nuwro:${{ matrix.tag_latest }}" \ | ||
--build-arg NUWRO_VERSION="develop" \ | ||
fi | ||
- name: Push Docker image | ||
run: | | ||
if [ "${{ github.ref_type }}" == "tag" ]; then | ||
docker push "ghcr.io/${{ github.repository_owner }}/nuwro:${{ matrix.os }}${{ github.ref_name }}" | ||
else | ||
docker push "ghcr.io/${{ github.repository_owner }}/nuwro:${{ matrix.tag_latest }}" | ||
fi | ||
- name: Delete old images | ||
uses: actions/delete-package-versions@v5 | ||
with: | ||
package-name: 'nuwro' | ||
package-type: 'container' | ||
min-versions-to-keep: 5 | ||
delete-only-untagged-versions: 'true' |
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 @@ | ||
--- | ||
# Check if NuWro compiles correctly | ||
|
||
name: Build CI | ||
|
||
# The events that trigger the workflow | ||
on: | ||
pull_request: | ||
branches: [ master ] | ||
|
||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false # KS: Prevents cancellation of remaining jobs if one fails | ||
matrix: | ||
include: | ||
- os: alma9 | ||
file: doc/docker/alma9/Dockerfile | ||
tag: alma9latest | ||
|
||
name: Build CI ${{ matrix.os }} | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Log in to GitHub Container Registry | ||
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | ||
|
||
- name: Build the Docker image | ||
run: docker build . --file ${{ matrix.file }} --tag ghcr.io/${{ github.repository_owner }}/nuwro:${{ matrix.tag }} --build-arg NUWRO_VERSION=${{ github.head_ref }} |
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,36 @@ | ||
FROM picker24/root_v6_26_10:alma9 AS nuwro_build | ||
WORKDIR / | ||
|
||
ARG NUWRO_VERSION=master | ||
ENV NUWRO_VERSION=${NUWRO_VERSION} | ||
|
||
ENV NUWRO_WORK_DIR=/opt/nuwro-src/ | ||
|
||
WORKDIR /opt/ | ||
RUN --mount=type=ssh git clone https://github.com/NuWro/nuwro.git ${NUWRO_WORK_DIR} | ||
WORKDIR /opt/nuwro-src | ||
RUN git checkout ${NUWRO_VERSION} | ||
|
||
RUN sed -i "s:-lPythia6:-L${PYTHIA6} -lPythia6:g" Makefile | ||
RUN make -j4 | ||
|
||
FROM picker24/root_v6_26_10:alma9 | ||
WORKDIR / | ||
|
||
RUN mkdir -p /opt/nuwro/build/src/dis | ||
RUN mkdir -p /opt/nuwro/build/src/espp | ||
RUN mkdir -p /opt/nuwro/build/src/sf | ||
RUN mkdir -p /opt/nuwro/build/src/rpa | ||
RUN mkdir -p /opt/nuwro/build/src/rew | ||
COPY --from=nuwro_build /opt/nuwro-src/data /opt/nuwro/build/data | ||
COPY --from=nuwro_build /opt/nuwro-src/bin /opt/nuwro/build/bin | ||
COPY --from=nuwro_build /opt/nuwro-src/src/*.h /opt/nuwro/build/src/ | ||
COPY --from=nuwro_build /opt/nuwro-src/src/dis/*.h /opt/nuwro/build/src/dis/ | ||
COPY --from=nuwro_build /opt/nuwro-src/src/espp/*.h /opt/nuwro/build/src/espp/ | ||
COPY --from=nuwro_build /opt/nuwro-src/src/sf/*.h /opt/nuwro/build/src/sf/ | ||
COPY --from=nuwro_build /opt/nuwro-src/src/rpa/*.h /opt/nuwro/build/src/rpa/ | ||
COPY --from=nuwro_build /opt/nuwro-src/src/rew/*.h /opt/nuwro/build/src/rew/ | ||
|
||
ENV NUWRO=/opt/nuwro/build | ||
ENV PATH=${NUWRO}/bin:${PATH} | ||
ENV ROOT_INCLUDE_PATH=${NUWRO}/src:${ROOT_INCLUDE_PATH} |