Skip to content

Commit 2bdef96

Browse files
authored
Update push-docker-image.yaml
1 parent 6c9d776 commit 2bdef96

File tree

1 file changed

+29
-15
lines changed

1 file changed

+29
-15
lines changed

Diff for: .github/workflows/push-docker-image.yaml

+29-15
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,41 @@
1-
name: Release
1+
name: release
2+
23
on:
34
push:
45
tags:
56
- 'v*.*.*'
6-
7+
78
env:
89
DOCKER_USER: ${{ secrets.DOCKER_USER }}
910
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
1011
REPO_NAME: ${{ secrets.REPO_NAME }}
1112
RELEASE_VERSION: ${{ steps.vars.outputs.tag }}
1213

1314
jobs:
14-
push-image-to-docker-hub: # job name
15-
runs-on: ubuntu-latest # runner name : (ubuntu latest version)
15+
push_to_registry:
16+
name: Push Docker image to Docker Hub
17+
runs-on: ubuntu-latest
1618
steps:
17-
- uses: actions/checkout@v2 # first action : checkout source code
18-
- name: docker login
19-
run: | # log into docker hub account
20-
docker login -u $DOCKER_USER -p $DOCKER_PASSWORD
21-
- name: Get current date # get the date of the build
22-
id: date
23-
run: echo "::set-output name=date::$(date +'%Y-%m-%d--%M-%S')"
24-
- name: Build the Docker image # push The image to the docker hub
25-
run: docker build . --file build/Dockerfile --tag $DOCKER_USER/$REPO_NAME:$RELEASE_VERSION
26-
- name: Docker Push
27-
run: docker push $DOCKER_USER/$REPO_NAME:$RELEASE_VERSION
19+
- name: Check out the repo
20+
uses: actions/checkout@v3
21+
22+
- name: Log in to Docker Hub
23+
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
24+
with:
25+
username: $DOCKER_USER
26+
password: $DOCKER_PASSWORD
27+
28+
- name: Extract metadata (tags, labels) for Docker
29+
id: meta
30+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
31+
with:
32+
images: $DOCKER_USER/$REPO_NAME
33+
34+
- name: Build and push Docker image
35+
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
36+
with:
37+
context: .
38+
file: ./build/Dockerfile
39+
push: true
40+
tags: $RELEASE_VERSION
41+
labels: ${{ steps.meta.outputs.labels }}

0 commit comments

Comments
 (0)