back to entrypoint on docker #101
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
name: cache dependencies, test, and build | |
on: | |
push: | |
branches: | |
- tickets/DM-45476 | |
tags: | |
- v* | |
pull_request: | |
env: | |
PROGRAM_NAME: transfer-embargo | |
EUPS_DISTRIB_VERSION: "w_2024_32" | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the repo | |
uses: actions/checkout@v3 | |
- name: Cache dependencies | |
uses: actions/cache@v2 | |
with: | |
path: ${{ github.workspace }}/conda/ | |
key: ${{ runner.os }}-eups-${{ env.EUPS_DISTRIB_VERSION }}-${{ hashFiles('**/*.txt') }} | |
- name: Install dependencies | |
run: | | |
curl -OL https://ls.st/lsstinstall | |
chmod u+x lsstinstall | |
./lsstinstall -T ${{ env.EUPS_DISTRIB_VERSION }} | |
source loadLSST.sh | |
eups distrib install -t ${{ env.EUPS_DISTRIB_VERSION }} obs_lsst | |
curl -sSL https://raw.githubusercontent.com/lsst/shebangtron/main/shebangtron | python | |
- name: Run tests | |
run: | | |
source loadLSST.sh | |
setup obs_lsst | |
cd ./tests | |
pytest test_move_embargo_args.py | |
build: | |
runs-on: ubuntu-latest | |
needs: test | |
steps: | |
- name: Checkout the repo | |
uses: actions/checkout@v3 | |
- name: docker build | |
run: | | |
docker build . \ | |
--tag $PROGRAM_NAME | |
- name: Log in to Github container registry | |
run: echo "${{ secrets.GITHUB_TOKEN }}" |docker login ghcr.io -u $ --password-stdin | |
- name: Push images | |
run: | | |
PROGRAM_ID=ghcr.io/${{ github.repository_owner }}/$PROGRAM_NAME | |
if [[ "${{ github.ref }}" == "refs/pull/"* ]]; then | |
VERSION=$(echo "${{ github.head_ref }}" | sed -e 's|.*/||') | |
elif [[ "${{ github.ref }}" == "refs/tags/"* ]]; then | |
VERSION=$(echo "${{ github.ref_name }}" | sed -e 's|^v||') | |
else | |
VERSION=latest | |
fi | |
echo VERSION=$VERSION | |
echo PROGRAM_ID=$PROGRAM_ID | |
docker tag $PROGRAM_NAME $PROGRAM_ID:$VERSION | |
docker push $PROGRAM_ID:$VERSION |