I'm trying to set up some CI tests using GitHub's Actions and its support for Docker containers. Specifically:
When a pull request is made, I want the GitHub action to build a docker container and use it build the code from the branch the pull request is being made from. I have tried passing the branch name using $GITHUB_REF as an input. However, all the entrypoint.sh script ever gets is literally "$GITHUB_REF" and never the resolved branch name.
Here are the relevant files:
name: C/C++ CI docker
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
JTest_job:
runs-on: ubuntu-latest
name: Full build with tests
# Build Docker container and run the entrypoint.sh script in it
steps:
- name: Build and run
id: build_and_run
uses: faustus123/DockerAction-JANA2@alpha
with:
branch: $GITHUB_REF
name: 'DockerAction-JANA2'
description: 'Build JANA2 and run JTest plugin'
inputs:
branch: # id of input
description: 'branch name'
required: false
default: 'master'
# This specifies that docker will be used and the Dockerfile that the
# image should be built from. The args section specifies arguments that
# should be passed to the container when it is run (not when the image
# is being built).
runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.branch }}
#!/bin/bash
#
# This is run from within the temporary janatest container
# that gets built by GitHub as part of a GitHub Action to test
# pull requests and commits to master.
#
# This builds JANA2 using the branch given as the only argument
# to this script. It also uses the CXX_STANDARD environment variable
# which should be set in the Dockerfile to be consistent with what
# the ROOT version used. (See Dockerfile for details.)
#
# n.b. The JANA software will be installed in /usr and the
# plugins in /plugins. This is in spite of setting the
# CMAKE_INSTALL_PREFIX below.
#
export BRANCH=$1
echo "--- Building JANA for branch $BRANCH --------------"
cd /opt/JANA2
git checkout $BRANCH
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=/opt/JANA2/Linux -DCMAKE_CXX_STANDARD=$CXX_STANDARD
make -j8 install
echo "------------------------"
echo "--- JTest --------------"
export JANA_PLUGIN_PATH=/plugins
jana -PPLUGINS=JTest -Pjana:nevents=100
echo "------------------------"
echo "--- tests --------------"
export JANA_PLUGIN_PATH=/plugins
tests
echo "------------------------"