Skip to content

teste1

teste1 #30

Workflow file for this run

name: Build and Deploy Application
on:
push:
branches:
- 'master'
- 'main'
- 'releases/**'
- 'release/**'
- 'develop'
- 'feature/**'
- 'feat/**'
- 'hotfix/**'
paths-ignore:
- 'docs/**'
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Create docker image name
id: docker-image
run: |
BRANCH_NAME=${{ github.ref_name }}
IMAGE_NAME=${BRANCH_NAME}_${{ github.sha }}
echo "IMAGE_NAME=${IMAGE_NAME}" >> $GITHUB_OUTPUT
- name: Extract repository name
id: extract-repository-name
run: |
REPO_NAME=$(echo "${{ github.repository }}" | cut -d '/' -f 2)
echo "REPO_NAME=${REPO_NAME}" >> $GITHUB_OUTPUT
- name: Login to Docker registry
uses: docker/login-action@v3
with:
registry: docker.io
username: '${{ secrets.DOCKER_USERNAME }}'
password: '${{ secrets.DOCKER_PASSWORD }}'
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: |
docker.io/${{ secrets.DOCKER_USERNAME }}/${{ steps.extract-repository-name.outputs.REPO_NAME }}:${{ steps.docker-image.outputs.IMAGE_NAME }}
- name: Extract Image sha256
id: image-digest
run: |
IMAGE_DIGEST=$(docker inspect --format='{{index .RepoDigests 0}}'
${{ github.repository_owner }}/${{ steps.extract-repository-name.outputs.REPO_NAME }}:
${{ steps.docker-image.outputs.IMAGE_NAME }} | cut -d "@" -f 2)
echo "IMAGE_DIGEST=${IMAGE_DIGEST}" >> $GITHUB_OUTPUT
- name: Setup yq portable command-line YAML, JSON, XML, CSV, TOML and properties processor
uses: mikefarah/[email protected]
- name: Update Yaml Files
run: |
helm_folder="${{ vars.NAME_HELM_FOLDER }}"
version_helm="$(cat VERSION_HELM)"
run_number="${{ github.run_number }}"
image_name="${{ steps.docker-image.outputs.IMAGE_NAME }}"
image_digest="${{ steps.image-digest.outputs.IMAGE_DIGEST }}"
yq -i ".version = \"${version_helm}.${run_number}\"" "./${helm_folder}/Chart.yaml"
yq -i ".appVersion = \"$(cat VERSION)\"" "./${helm_folder}/Chart.yaml"
yq -i '.image.tag = "'"${image_name}@${image_digest}"'"' "./${helm_folder}/values.yaml"
- name: Set up Helm
uses: azure/setup-helm@v3
with:
version: 'v3.11.1'
- name: Package Helm Chart
run: |
helm package ./${{ vars.NAME_HELM_FOLDER }}
helm repo index ./${{ vars.NAME_HELM_FOLDER }} --url ${{ vars.URL_HELM_REPOSITORY }}
- name: Clone Helm Chart Repo
uses: actions/checkout@v3
with:
repository: eduardo854/helm-store
ref: stage
token: '${{ secrets.TOKEN_HELM_STORE }}'
path: ./helm-store
- name: Copy Chart Package
run: |
mkdir -p helm-store/app/${{ steps.extract-repository-name.outputs.REPO_NAME }}
cp *.tgz helm-store/app/${{ steps.extract-repository-name.outputs.REPO_NAME }}/
- name: Commit and Push Changes
run: |
cd helm-store/
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
git pull origin stage
git add .
git commit -m "${{ github.ref_name }}"
git push origin stage