change github workflow branch to main #4
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
name: Build Docker Image and Push Helm Chart | |
on: | |
push: | |
branches: | |
- dev | |
- main | |
tags: | |
- '*' | |
workflow_dispatch: | |
jobs: | |
docker: | |
runs-on: ${{ vars.RUNNER_SCALE_SET }} | |
steps: | |
- name: Import Secrets from Vault | |
id: vault | |
uses: hashicorp/vault-action@v3 | |
with: | |
url: ${{ vars.VAULT_ADDR }} | |
path: ${{ vars.VAULT_PATH }} | |
method: kubernetes | |
role: ${{ vars.VAULT_ROLE }} | |
secrets: | | |
${{ vars.VAULT_PATH }}/data/${{ vars.VAULT_SECRET_PATH }} * | |
- name: Login to Docker Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.DOCKER_REGISTRY }} | |
username: ${{ env.DOCKER_USERNAME }} | |
password: ${{ env.DOCKER_PASSWORD }} | |
- name: Setup Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_PROJECT }}/${{ vars.DOCKER_IMAGE }} | |
tags: | | |
type=ref,event=branch | |
type=ref,event=pr | |
type=semver,pattern={{version}} | |
- name: Build and Push Docker image | |
uses: docker/build-push-action@v6 | |
with: | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
helm: | |
if: github.ref_type == 'tag' | |
runs-on: ${{ vars.RUNNER_SCALE_SET }} | |
steps: | |
- name: Import Secrets from Vault | |
id: vault | |
uses: hashicorp/vault-action@v3 | |
with: | |
url: ${{ vars.VAULT_ADDR }} | |
path: ${{ vars.VAULT_PATH }} | |
method: kubernetes | |
role: ${{ vars.VAULT_ROLE }} | |
secrets: | | |
${{ vars.VAULT_PATH }}/data/${{ vars.VAULT_SECRET_PATH }} * | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
tags: | | |
type=semver,pattern={{version}} | |
flavor: | | |
latest=false | |
- name: Install Helm | |
uses: azure/[email protected] | |
- name: Push Helm Chart | |
uses: appany/[email protected] | |
with: | |
name: ${{ vars.DOCKER_IMAGE }} | |
repository: charts | |
tag: ${{ steps.meta.outputs.tags }} | |
path: deploy/chart | |
registry: ${{ env.DOCKER_REGISTRY }} | |
registry_username: ${{ env.DOCKER_USERNAME }} | |
registry_password: ${{ env.DOCKER_PASSWORD }} |