-
Notifications
You must be signed in to change notification settings - Fork 0
36 lines (28 loc) · 1.06 KB
/
docker-image.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
name: Docker Image CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Set up Docker Buildx (optional, but recommended for multi-platform builds)
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
# Log in to ghcr.io
- name: Log in to GitHub Container Registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
# Define image tag as an environment variable
- name: Define image tag
id: vars
run: echo "IMAGE_TAG=$(date +%s)" >> $GITHUB_ENV
# Build the Docker image
- name: Build the Docker image
run: docker build . --file ./CloudProject/Dockerfile --tag ghcr.io/${{ github.repository_owner }}/cloud_ci_cd_image:${{ env.IMAGE_TAG }}
# Push the Docker image to ghcr.io
- name: Push the Docker image
run: docker push ghcr.io/${{ github.repository_owner }}/cloud_ci_cd_image:${{ env.IMAGE_TAG }}