Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

Commit

Permalink
Create build-and-push-main.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
tnix100 authored Aug 10, 2024
1 parent bc9a67e commit 005b802
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/build-and-push-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Build and Push Docker Image

on:
push:
branches: [ "main" ]

jobs:

build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.20'

- name: Build image
run: |
IMAGE_NAME=ghcr.io/${{ github.repository }}
docker build -t $IMAGE_NAME:${{ github.sha }} -t $IMAGE_NAME:latest .
- name: Login to GHCR.io
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- name: Push the image to GHCR.io
run: |
IMAGE_NAME=ghcr.io/${{ github.repository }}
docker push ghcr.io/${{ github.repository }}:${{ github.sha }}
docker push ghcr.io/${{ github.repository }}:latest

0 comments on commit 005b802

Please sign in to comment.