Skip to content

Docker Images Debian #254

Docker Images Debian

Docker Images Debian #254

Workflow file for this run

name: Docker Images Debian
on:
push:
branches:
- main
tags:
- v*
pull_request:
branches:
- main
schedule:
- cron: '1 0 * * 0'
release:
types: [published]
workflow_dispatch:
jobs:
docker:
name: Build and publish Debian images
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Prepare
id: prep
run: |
DOCKER_IMAGE=scailfin/madgraph5-amc-nlo
VERSION=latest
MADGRAPH_VERSION=mg5_amc3.5.1
REPO_NAME=${{github.repository}}
REPO_NAME_LOWERCASE="${REPO_NAME,,}"
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
elif [[ $GITHUB_REF == refs/pull/* ]]; then
VERSION=pr-${{ github.event.number }}
fi
TAGS="${DOCKER_IMAGE}:${VERSION}"
TAGS="$TAGS,${DOCKER_IMAGE}:latest,${DOCKER_IMAGE}:${MADGRAPH_VERSION},${DOCKER_IMAGE}:sha-${GITHUB_SHA::8}"
# Releases also have GITHUB_REFs that are tags, so reuse VERSION
if [ "${{ github.event_name }}" = "release" ]; then
TAGS="$TAGS,${DOCKER_IMAGE}:latest-stable,ghcr.io/${REPO_NAME_LOWERCASE}:latest-stable,ghcr.io/${REPO_NAME_LOWERCASE}:${VERSION}"
fi
echo ::set-output name=version::${VERSION}
echo ::set-output name=tags::${TAGS}
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
echo ::set-output name=repo_name_lowercase::"${REPO_NAME_LOWERCASE}"
echo ::set-output name=madgraph_version::"${MADGRAPH_VERSION}"
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Test build
id: docker_build_test
uses: docker/build-push-action@v2
with:
context: .
file: docker/debian/Dockerfile
tags: ${{ steps.prep.outputs.tags }}
labels: |
org.opencontainers.image.source=${{ github.event.repository.html_url }}
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.revision=${{ github.sha }}
load: true
push: false
- name: Image digest
run: echo ${{ steps.docker_build_test.outputs.digest }}
- name: List built images
run: docker images
- name: List MadGraph5 configuration file
run: >-
docker run --rm
scailfin/madgraph5-amc-nlo:sha-${GITHUB_SHA::8}
'cat $(find /usr/local/ -name "mg5_configuration.txt")'
- name: Run pytest tests
# Need to run not below PWD to have non-root write with GHA
run: >-
docker run --rm
-v $PWD:$PWD
scailfin/madgraph5-amc-nlo:sha-${GITHUB_SHA::8}
"cp -r ${PWD}/tests .; python -m pip install pytest && pytest tests"
- name: Run test program
# Need to run not below PWD to have non-root write with GHA
run: >-
docker run --rm
-v $PWD:$PWD
scailfin/madgraph5-amc-nlo:sha-${GITHUB_SHA::8}
"cp -r ${PWD}/tests .; cd tests; bash tests.sh"
- name: Test madevent has valid root_path
run: >-
docker run --rm
-v $PWD:$PWD
scailfin/madgraph5-amc-nlo:sha-${GITHUB_SHA::8}
"cp -r ${PWD}/tests .; cd tests; bash test_root_path.sh"
- name: Check NLO process has dependencies
run: >-
docker run --rm
-v $PWD:$PWD
scailfin/madgraph5-amc-nlo:sha-${GITHUB_SHA::8}
"cp -r ${PWD}/tests/* .; mg5_aMC test_NLO.mg5"
- name: Build and publish to registry
# every PR will trigger a push event on main, so check the push event is actually coming from main
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository == 'scailfin/MadGraph5_aMC-NLO'
id: docker_build_latest
uses: docker/build-push-action@v2
with:
context: .
file: docker/debian/Dockerfile
tags: |
scailfin/madgraph5-amc-nlo:latest
scailfin/madgraph5-amc-nlo:${{ steps.prep.outputs.madgraph_version }}
ghcr.io/${{ steps.prep.outputs.repo_name_lowercase }}:latest
ghcr.io/${{ steps.prep.outputs.repo_name_lowercase }}:${{ steps.prep.outputs.madgraph_version }}
labels: |
org.opencontainers.image.source=${{ github.event.repository.html_url }}
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.revision=${{ github.sha }}
push: true
- name: Build and publish to registry with release tag
if: github.event_name == 'release' && github.event.action == 'published' && github.repository == 'scailfin/MadGraph5_aMC-NLO'
id: docker_build_release
uses: docker/build-push-action@v2
with:
context: .
file: docker/debian/Dockerfile
tags: ${{ steps.prep.outputs.tags }}
labels: |
org.opencontainers.image.source=${{ github.event.repository.html_url }}
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.revision=${{ github.sha }}
push: true