Skip to content

Commit

Permalink
workflow to deploy docker images based on main branch content to the …
Browse files Browse the repository at this point in the history
…github registry
  • Loading branch information
htrgouvea committed Nov 28, 2024
1 parent 79336c0 commit 3954cfc
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/deploy-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Deploy to GitHub Container Registry

on:
push:
branches:
- main

jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build Docker image
id: build
run: |
COMMIT_SHA=$(echo "${GITHUB_SHA}" | cut -c1-7)
IMAGE_NAME="ghcr.io/${{ github.repository }}/sentra"
docker build --file Dockerfile --tag ${IMAGE_NAME}:latest --tag ${IMAGE_NAME}:${COMMIT_SHA} .
echo "IMAGE_NAME=${IMAGE_NAME}" >> $GITHUB_ENV
echo "COMMIT_SHA=${COMMIT_SHA}" >> $GITHUB_ENV
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.LESIS_DEPLOY }}

- name: Push Docker image to GitHub Container Registry
run: |
docker push ${{ env.IMAGE_NAME }}:latest
docker push ${{ env.IMAGE_NAME }}:${{ env.COMMIT_SHA }}

0 comments on commit 3954cfc

Please sign in to comment.