Skip to content

Commit a714a17

Browse files
authored
Add GitHub Actions workflow for Docker build and push
1 parent 605d75a commit a714a17

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

.github/workflows/docker-build.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Build and Push Docker Image
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
7+
jobs:
8+
docker:
9+
runs-on: ubuntu-latest
10+
environment: Dev-Demo
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
- name: Log in to Docker Hub
17+
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
18+
19+
- name: Build and Push Docker Image
20+
run: |
21+
IMAGE_NAME=${{ secrets.DOCKER_USERNAME }}/hello-world-actions
22+
docker build -t $IMAGE_NAME:${{ github.sha }} .
23+
docker push $IMAGE_NAME:${{ github.sha }}
24+
echo "Image pushed: $IMAGE_NAME:${{ github.sha }}"

0 commit comments

Comments
 (0)