88 pull_request :
99 branches : [ master, webapi-3.0 ]
1010
11- env :
12- DOCKER_IMAGE : ohdsi/webapi
13-
1411jobs :
1512 # Build and test the code
1613 build :
2320 # Steps represent a sequence of tasks that will be executed as part of the job
2421 steps :
2522 # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
26- - uses : actions/checkout@v2
23+ - uses : actions/checkout@v4
2724
2825 - uses : actions/setup-java@v4
2926 with :
@@ -47,15 +44,24 @@ jobs:
4744 run : mvn -B -P${{ env.MAVEN_PROFILE }} test
4845
4946 # Check that the docker image builds correctly
50- # Push to ohdsi/atlas:master for commits on master.
47+ # Push to ghcr.io for commits on master or webapi-3.0 .
5148 docker :
5249 # The type of runner that the job will run on
5350 runs-on : ubuntu-latest
5451
5552 # Steps represent a sequence of tasks that will be executed as part of the job
5653 steps :
5754 # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
58- - uses : actions/checkout@v2
55+ - uses : actions/checkout@v4
56+
57+ - name : Set Docker image name
58+ run : |
59+ REPO="${GITHUB_REPOSITORY:-ohdsi/webapi}"
60+ DOCKER_IMAGE="ghcr.io/$(echo "${REPO}" | tr '[:upper:]' '[:lower:]')"
61+ echo "DOCKER_IMAGE=${DOCKER_IMAGE}" >> $GITHUB_ENV
62+
63+ - name : Debug Docker image name
64+ run : echo "DOCKER_IMAGE=${DOCKER_IMAGE}"
5965
6066 - name : Cache Docker layers
6167 uses : actions/cache@v4
@@ -68,40 +74,54 @@ jobs:
6874 # Add Docker labels and tags
6975 - name : Docker meta
7076 id : docker_meta
71- uses : crazy-max/ghaction-docker-meta@v1
77+ uses : docker/metadata-action@v5
7278 with :
7379 images : ${{ env.DOCKER_IMAGE }}
80+ tags : |
81+ type=raw,value=dev,enable=${{ github.ref == 'refs/heads/master' }}
82+ type=raw,value=3.0-dev,enable=${{ github.ref == 'refs/heads/webapi-3.0' }}
83+ type=sha,prefix=pr-,enable=${{ github.event_name == 'pull_request' }}
84+ type=ref,event=branch,prefix=branch-,enable=${{ github.ref != 'refs/heads/master' && github.ref != 'refs/heads/webapi-3.0' }}
85+
86+ - name : Debug Docker metadata
87+ run : |
88+ echo "Docker metadata outputs:"
89+ echo "version: ${{ steps.docker_meta.outputs.version }}"
90+ echo "tags: ${{ steps.docker_meta.outputs.tags }}"
91+ echo "labels: ${{ steps.docker_meta.outputs.labels }}"
92+ echo "json: ${{ steps.docker_meta.outputs.json }}"
7493
7594 # Setup docker build environment
7695 - name : Set up QEMU
77- uses : docker/setup-qemu-action@v1
96+ uses : docker/setup-qemu-action@v3
7897 - name : Set up Docker Buildx
79- uses : docker/setup-buildx-action@v1
98+ uses : docker/setup-buildx-action@v3
8099
81100 - name : Set build parameters
82101 id : build_params
83102 run : |
84- echo "::set-output name= sha8:: ${GITHUB_SHA::8}"
85- if [ "${{ github.event_name }}" != "pull_request" ] && [ "${{ github.ref }}" == "refs/heads/master" ]; then
86- echo "::set-output name= push:: true"
87- echo "::set-output name= load:: false"
88- echo "::set-output name= platforms:: linux/amd64,linux/arm64"
103+ echo "sha8= ${GITHUB_SHA::8}" >> $GITHUB_OUTPUT
104+ if [ "${{ github.event_name }}" != "pull_request" ] && ( [ "${{ github.ref }}" == "refs/heads/master" ] || [ "${{ github.ref }}" == "refs/heads/webapi-3.0" ] ) ; then
105+ echo "push= true" >> $GITHUB_OUTPUT
106+ echo "load= false" >> $GITHUB_OUTPUT
107+ echo "platforms= linux/amd64,linux/arm64" >> $GITHUB_OUTPUT
89108 else
90- echo "::set-output name= push:: false"
91- echo "::set-output name= load:: true"
92- echo "::set-output name= platforms:: linux/amd64"
109+ echo "push= false" >> $GITHUB_OUTPUT
110+ echo "load= true" >> $GITHUB_OUTPUT
111+ echo "platforms= linux/amd64" >> $GITHUB_OUTPUT
93112 fi
94113
95- - name : Login to DockerHub
96- uses : docker/login-action@v1
114+ - name : Login to GitHub Container Registry
115+ uses : docker/login-action@v3
97116 if : steps.build_params.outputs.push == 'true'
98117 with :
99- username : ${{ secrets.DOCKER_HUB_USERNAME }}
100- password : ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
118+ registry : ghcr.io
119+ username : ${{ github.actor }}
120+ password : ${{ secrets.GITHUB_TOKEN }}
101121
102122 - name : Build and push
103123 id : docker_build
104- uses : docker/build-push-action@v2
124+ uses : docker/build-push-action@v5
105125 with :
106126 context : ./
107127 file : ./Dockerfile
@@ -113,6 +133,7 @@ jobs:
113133 build-args : |
114134 GIT_BRANCH=${{ steps.docker_meta.outputs.version }}
115135 GIT_COMMIT_ID_ABBREV=${{ steps.build_params.outputs.sha8 }}
136+ MAVEN_PROFILE=webapi-docker,tcache
116137 tags : ${{ steps.docker_meta.outputs.tags }}
117138 # Use runtime labels from docker_meta as well as fixed labels
118139 labels : |
0 commit comments