-
Notifications
You must be signed in to change notification settings - Fork 1
39 lines (32 loc) · 1.14 KB
/
dockerhub-push-nodejs.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
name: Docker Hub Push for nodejs
on:
push:
branches:
- "music-uploader/develop"
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set Environment Variables
run: |
BRANCH_NAME=$(echo $GITHUB_REF | awk -F'/' '{print $3}')
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
- name: Build and Push Docker Image
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
BRANCH_NAME: ${{ env.BRANCH_NAME }}
run: |
if [ -n "$BRANCH_NAME" ]; then
DOCKERFILE_DIR="src/backend/$BRANCH_NAME-server"
else
echo "Failed to extract branch name from GITHUB_REF."
exit 1
fi
cd $DOCKERFILE_DIR
docker run --privileged --rm tonistiigi/binfmt --install all
docker buildx create --use
docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
docker buildx build --platform=linux/amd64,linux/arm64 -t $DOCKER_USERNAME/$BRANCH_NAME:latest . --push