Skip to content

Commit c80f38d

Browse files
committed
build: push image to both Google Artifact
and Docker Hub
1 parent 1d1683c commit c80f38d

1 file changed

Lines changed: 31 additions & 2 deletions

File tree

.github/workflows/prod-build.yml

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ env:
2525
DOCKER_HUB_PASSWORD : ${{ secrets.DOCKER_HUB_PASSWORD }}
2626
REPOSITORY_NAME: nmrium-react-wrapper
2727
REPOSITORY_NAMESPACE: nfdi4chem
28+
REPOSITORY_NAME_PROD: nmrxiv-prod
29+
IMAGE: nmrium
2830

2931
jobs:
3032
setup-build-publish-deploy-prod:
@@ -42,14 +44,19 @@ jobs:
4244
service_account_key: ${{ secrets.GKE_SA_KEY }}
4345
project_id: ${{ secrets.GKE_PROJECT }}
4446

47+
# Configure docker to use the gcloud command-line tool as a credential helper
48+
- name: Configure docker
49+
run: |-
50+
gcloud auth configure-docker europe-west3-docker.pkg.dev
51+
4552
# Get the GKE credentials so we can deploy to the cluster
4653
- name: Get GKE credentials
4754
uses: google-github-actions/get-gke-credentials@v0.3.0
4855
with:
4956
cluster_name: ${{ env.GKE_CLUSTER_PROD }}
5057
location: ${{ env.GKE_ZONE }}
5158
credentials: ${{ secrets.GKE_SA_KEY }}
52-
59+
5360
#Fetch latest release
5461
- name: Fetch latest release
5562
id: fetch-latest-release
@@ -62,7 +69,29 @@ jobs:
6269
run: |
6370
echo "tag_name: ${{ steps.fetch-latest-release.outputs.tag_name }}"
6471
65-
#Build and push Docker image
72+
# Build the Docker image
73+
- name: Build docker image
74+
run: |-
75+
if [ ${{ steps.fetch-latest-release.outputs.tag_name }} ]; then
76+
docker build --build-arg RELEASE_VERSION=${{ steps.fetch-latest-release.outputs.tag_name }} -f Dockerfile.prod --tag europe-west3-docker.pkg.dev/$PROJECT_ID/$REPOSITORY_NAME_PROD/$IMAGE:latest .
77+
else
78+
echo "Skipping build as no release available.";
79+
fi
80+
81+
# Push the Docker image to Google Artifact Registry
82+
- name: Publish image to Google Artifact Registry
83+
if: ${{ steps.fetch-latest-release.outputs.tag_name }}
84+
run: |-
85+
docker push "europe-west3-docker.pkg.dev/$PROJECT_ID/$REPOSITORY_NAME_PROD/$IMAGE:latest"
86+
87+
#Login to Docker Hub
88+
- name: Log in to Docker Hub
89+
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
90+
with:
91+
username: ${{ env.DOCKER_HUB_USERNAME }}
92+
password: ${{ env.DOCKER_HUB_PASSWORD }}
93+
94+
#Build and push Docker image to Docker Hub
6695
- name: Build and push Docker image
6796
uses: docker/build-push-action@v4
6897
with:

0 commit comments

Comments
 (0)