Skip to content

Commit

Permalink
Create build-container.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
gpillon authored Sep 15, 2024
1 parent 59a698f commit 38e2a2a
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/build-container.yaml
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 }}"

0 comments on commit 38e2a2a

Please sign in to comment.