Skip to content

Commit a4bb601

Browse files
committed
build: move docker image to Docker Hub
1 parent efbb97b commit a4bb601

1 file changed

Lines changed: 16 additions & 21 deletions

File tree

.github/workflows/prod-build.yml

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ env:
2121
GKE_CLUSTER_PROD: nmrxiv-prod
2222
GKE_ZONE: europe-west3-a
2323
DEPLOYMENT_NAME: nmrxiv-nmrium
24-
REPOSITORY_NAME_PROD: nmrxiv-prod
25-
IMAGE: nmrium
24+
DOCKER_HUB_USERNAME : ${{ secrets.DOCKER_HUB_USERNAME }}
25+
DOCKER_HUB_PASSWORD : ${{ secrets.DOCKER_HUB_PASSWORD }}
26+
REPOSITORY_NAME: nmrium-react-wrapper
27+
REPOSITORY_NAMESPACE: nfdi4chem
2628

2729
jobs:
2830
setup-build-publish-deploy-prod:
@@ -40,11 +42,6 @@ jobs:
4042
service_account_key: ${{ secrets.GKE_SA_KEY }}
4143
project_id: ${{ secrets.GKE_PROJECT }}
4244

43-
# Configure docker to use the gcloud command-line tool as a credential helper
44-
- name: Configure docker
45-
run: |-
46-
gcloud auth configure-docker europe-west3-docker.pkg.dev
47-
4845
# Get the GKE credentials so we can deploy to the cluster
4946
- name: Get GKE credentials
5047
uses: google-github-actions/get-gke-credentials@v0.3.0
@@ -65,14 +62,18 @@ jobs:
6562
run: |
6663
echo "tag_name: ${{ steps.fetch-latest-release.outputs.tag_name }}"
6764
68-
# Build the Docker image
69-
- name: Build docker image
70-
run: |-
71-
if [ ${{ steps.fetch-latest-release.outputs.tag_name }} ]; then
72-
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 .
73-
else
74-
echo "Skipping build as no release available.";
75-
fi
65+
#Build and push Docker image
66+
- name: Build and push Docker image
67+
uses: docker/build-push-action@v4
68+
with:
69+
context: .
70+
file: ./Dockerfile.prod
71+
push: true
72+
build-args: |
73+
RELEASE_VERSION=${{ steps.fetch-latest-release.outputs.tag_name }}
74+
tags: ${{ env.REPOSITORY_NAMESPACE }}/${{ env.REPOSITORY_NAME }}:${{ steps.fetch-latest-release.outputs.tag_name }}
75+
username: ${{ env.DOCKER_HUB_USERNAME }}
76+
password: ${{ env.DOCKER_HUB_PASSWORD }}
7677

7778
# Build npm for release
7879
- name: Build npm
@@ -87,12 +88,6 @@ jobs:
8788
with:
8889
default_author: github_actions
8990

90-
# Push the Docker image to Google Artifact Registry
91-
- name: Publish image to Google Artifact Registry
92-
if: ${{ steps.fetch-latest-release.outputs.tag_name }}
93-
run: |-
94-
docker push "europe-west3-docker.pkg.dev/$PROJECT_ID/$REPOSITORY_NAME_PROD/$IMAGE:latest"
95-
9691
# Deploy the latest Docker image to the GKE cluster
9792
- name: Deploy
9893
if: ${{ steps.fetch-latest-release.outputs.tag_name }}

0 commit comments

Comments
 (0)