Skip to content

Commit

Permalink
🌱 add Release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
anngdinh committed Jun 26, 2024
1 parent bc9f52f commit b33ea2e
Showing 1 changed file with 45 additions and 18 deletions.
63 changes: 45 additions & 18 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -1,43 +1,70 @@
name: Create and publish a Docker image
name: Release

# RELEASE="v1.0.9" bash -c 'git tag $RELEASE && git push origin $RELEASE'

on:
release:
types: [published]
push:
tags:
- "v*" # Triggers on version tags, e.g., v1.0.0

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
REPO: vcr.vngcloud.vn/81-vks-public

jobs:
build-and-push-image:
build_package:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- image: vngcloud-ingress-controller
- image: vngcloud-controller-manager
permissions:
contents: read
contents: write
packages: write

steps:
- name: Checkout repository
uses: actions/[email protected]

- name: Log in to the Container registry
- name: Log in to the GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
- name: Debug
run: echo ${{ github.ref_name }}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
VERSION=${{ github.ref_name }}
platforms: linux/amd64
outputs: type=registry
tags: |
ghcr.io/vngcloud/${{ matrix.image }}:${{ github.sha }}
ghcr.io/vngcloud/${{ matrix.image }}:${{ github.ref_name }}
${{ env.REPO }}/${{ matrix.image }}:${{ github.sha }}
${{ env.REPO }}/${{ matrix.image }}:${{ github.ref_name }}
target: ${{ matrix.image }}

create_release:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref_name }}
run: |
gh release create "${{ github.ref_name }}" \
--repo="$GITHUB_REPOSITORY" \
--title="${{ github.ref_name }}" \
--generate-notes

0 comments on commit b33ea2e

Please sign in to comment.