-
Notifications
You must be signed in to change notification settings - Fork 0
42 lines (34 loc) · 1.08 KB
/
docker_publish.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
40
41
42
name: Build and Publish Docker Image
on:
push:
tags:
- "*" # Trigger on any tag push
workflow_dispatch:
jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
# Checkout the code
- name: Checkout code
uses: actions/checkout@v4
# Set up Docker Buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# Log in to GitHub Container Registry
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Extract the tag name from the push event
- name: Get Git Tag
id: get_tag
run: echo "TAG=${GITHUB_REF##*/}" >> $GITHUB_ENV
# Build the Docker image
- name: Build Docker image
run: |
docker build -t ghcr.io/${{ github.repository }}:${{ env.TAG }} .
# Push the Docker image to GitHub Container Registry
- name: Push Docker image
run: |
docker push ghcr.io/${{ github.repository }}:${{ env.TAG }}