Skip to content

Commit a629916

Browse files
authored
Update docker.yml
1 parent d4f5e42 commit a629916

File tree

1 file changed

+24
-31
lines changed

1 file changed

+24
-31
lines changed

.github/workflows/docker.yml

Lines changed: 24 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Docker Publish
1+
name: Build & Publish Docker Image
22

33
on:
44
push:
@@ -7,35 +7,28 @@ on:
77
workflow_dispatch:
88

99
jobs:
10-
build:
11-
name: Build Docker Image
10+
build-and-push:
1211
runs-on: ubuntu-latest
13-
1412
steps:
15-
- name: Checkout code
16-
uses: actions/checkout@v3
17-
18-
- name: Docker Hub Login (Optional but Recommended)
19-
run: docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_TOKEN }}
20-
21-
- name: Build and Tag Docker Image
22-
run: |
23-
IMAGE_NAME=pymmdrza/pyexplorer
24-
IMAGE_TAG=latest
25-
docker build -t ${IMAGE_NAME}:${IMAGE_TAG} .
26-
echo "IMAGE_NAME=${IMAGE_NAME}" >> $GITHUB_ENV
27-
echo "IMAGE_TAG=${IMAGE_TAG}" >> $GITHUB_ENV
28-
29-
push:
30-
name: Push Docker Image to Docker Hub
31-
runs-on: ubuntu-latest
32-
needs: build
33-
steps:
34-
- name: Docker Hub Login
35-
run: docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_TOKEN }}
36-
37-
- name: Load Docker Image from Build Job
38-
run: docker load -i <(docker save ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }})
39-
40-
- name: Push Docker Image
41-
run: docker push ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
15+
16+
- name: Log in to Docker Hub
17+
uses: docker/login-action@v3
18+
with:
19+
username: ${{ secrets.DOCKERHUB_USERNAME }}
20+
password: ${{ secrets.DOCKERHUB_TOKEN }}
21+
22+
- name: Extract metadata for Docker
23+
id: meta
24+
uses: docker/metadata-action@v5
25+
with:
26+
images: pymmdrza/pyexplorer
27+
28+
- name: Build and push Docker image
29+
uses: docker/build-push-action@v5
30+
with:
31+
context: .
32+
push: true
33+
tags: pymmdrza/pyexplorer:latest
34+
labels: ${{ steps.meta.outputs.labels }}

0 commit comments

Comments
 (0)