diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml new file mode 100644 index 0000000..a6045f8 --- /dev/null +++ b/.github/workflows/docker-build.yml @@ -0,0 +1,72 @@ +name: Build and Push Docker Image + +on: + push: + branches: + - main + tags: + - 'v*' + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Check out the code + uses: actions/checkout@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker (tag) + id: meta-tag + if: github.ref_type == 'tag' + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=semver,pattern=v{{version}} + type=semver,pattern=v{{major}}.{{minor}} + type=semver,pattern=v{{major}} + + - name: Extract metadata (tags, labels) for Docker (branch) + id: meta-branch + if: github.ref_type == 'branch' + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=sha,prefix={{branch}}-{{date 'YYYYMMDDHHmmss'}}- + + - name: Build and Push Docker Image (tag) + if: github.ref_type == 'tag' + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.meta-tag.outputs.tags }} + labels: ${{ steps.meta-tag.outputs.labels }} + + - name: Build and Push Docker Image (branch) + if: github.ref_type == 'branch' + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.meta-branch.outputs.tags }} + labels: ${{ steps.meta-branch.outputs.labels }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..05467bf --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,18 @@ +name: Main + +on: + push: + tags: + - "v*" + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Release + uses: softprops/action-gh-release@v2 + with: + generate_release_notes: true \ No newline at end of file