-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: Build and Push Container | ||
|
||
'on': | ||
push: | ||
branches: | ||
- main # Trigger on pushes to the main branch | ||
tags: | ||
- v* # Trigger on version tags like v1.0.0 | ||
workflow_dispatch: null # Allows manual trigger from the GitHub UI | ||
|
||
jobs: | ||
build-and-push: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out the repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Log in to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Extract version | ||
id: get_version | ||
shell: bash | ||
run: | | ||
VERSION=$(git describe --tags --abbrev=0) | ||
echo "::set-output name=version::$VERSION" | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
push: true | ||
tags: ghcr.io/${{ github.repository_owner }}/myapp:${{ steps.get_version.outputs.version }} | ||
|
||
- name: Update GitHub Deployment Status | ||
run: | | ||
echo "Container released: ghcr.io/${{ github.repository_owner }}/myapp:${{ steps.get_version.outputs.version }}" |