fix: security #55
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: 1. Non-production deployment | |
env: | |
HELM_CHART_NAME: oci://ghcr.io/gimlet-io/onechart | |
HELM_CHART_VERSION: "0.73.0" | |
# Environment name for main/master branch eg. dev or uat | |
MAIN_BRANCH_ENV_NAME: dev | |
SONARQUBE_ARGS: -D sonar.python.version=3.12 | |
on: | |
push: | |
paths-ignore: | |
- 'README.md' | |
- 'Makefile' | |
- 'docker-compose.yml' | |
- '.gitignore' | |
- 'requirements-orig-*.txt' | |
- '.devcontainer/**' | |
- 'iac/**' | |
branches: | |
- 'main' | |
jobs: | |
setup: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set DEPLOY_ENV | |
run: | | |
if [[ ${{ github.ref_name }} == 'main' || ${{ github.ref_name }} == 'master' ]]; then | |
# You can change this to uat for main/master branch in case of you have more than dev and production environment | |
echo "DEPLOY_ENV=${{ env.MAIN_BRANCH_ENV_NAME }}" >> "$GITHUB_ENV" | |
echo "DEPLOY_URL=https://demo-linebot.${{ env.MAIN_BRANCH_ENV_NAME }}.opsta.dev" >> "$GITHUB_ENV" | |
else | |
echo "DEPLOY_ENV=${{ github.ref_name }}" >> "$GITHUB_ENV" | |
echo "DEPLOY_URL=https://demo-linebot.${{ github.ref_name }}.opsta.dev" >> "$GITHUB_ENV" | |
fi | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
# list of Docker images to use as base name for tags | |
images: ${{ vars.IMAGE_NAME }} | |
# generate Docker tags based on the following events/attributes | |
tags: | | |
# branch event | |
type=ref,event=branch | |
# tag edge on default branch | |
type=edge | |
# dynamically set the branch name as a prefix | |
type=sha,prefix=${{ env.DEPLOY_ENV }}-,priority=750 | |
# For use in other jobs | |
# Need to put a lot of variables here because reusable workflow context not support env.* | |
outputs: | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
image_tag: ${{ steps.meta.outputs.version }} | |
deploy_env: ${{ env.DEPLOY_ENV }} | |
deploy_url: ${{ env.DEPLOY_URL }} | |
sonarqube_args: ${{ env.SONARQUBE_ARGS }} | |
helm_values_file: "${{ vars.HELM_VALUES_PATH }}/${{ vars.PREFIX_IAC_FILENAME }}-${{ env.DEPLOY_ENV }}.yaml" | |
helm_chart_name: ${{ env.HELM_CHART_NAME }} | |
helm_chart_version: ${{ env.HELM_CHART_VERSION }} | |
argocd_app_name: ${{ vars.PREFIX_K8S_NAMESPACE }}-${{ env.DEPLOY_ENV }}/${{ vars.PREFIX_IAC_FILENAME }}-${{ env.DEPLOY_ENV }} | |
# SECURITY PIPELINE | |
sec-predeploy: | |
uses: opsta/.github/.github/workflows/security-predeploy.yaml@main | |
needs: | |
- setup | |
with: | |
github_repo_name: ${{ github.event.repository.name }} | |
image_tag: ${{ needs.setup.outputs.image_tag }} | |
deploy_env: ${{ needs.setup.outputs.deploy_env }} | |
sonarqube_args: ${{ needs.setup.outputs.sonarqube_args }} | |
helm_values_file: ${{ needs.setup.outputs.helm_values_file }} | |
helm_chart_name: ${{ needs.setup.outputs.helm_chart_name }} | |
helm_chart_version: ${{ needs.setup.outputs.helm_chart_version }} | |
secrets: | |
sonarqube_org: ${{ secrets.SONARQUBE_ORG }} | |
sonarqube_host: ${{ secrets.SONARQUBE_HOST }} | |
sonarqube_token: ${{ secrets.SONARQUBE_TOKEN }} | |
build-push: | |
runs-on: ubuntu-latest | |
needs: | |
- setup | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Login to Container Registry | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ vars.IMAGE_REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build and push | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ needs.setup.outputs.tags }} | |
labels: ${{ needs.setup.outputs.labels }} | |
# SECURITY VULNERABILITY | |
# cache-to: type=registry,ref=${{ vars.IMAGE_NAME }}:buildcache-vuln,mode=max | |
# cache-from: type=registry,ref=${{ vars.IMAGE_NAME }}:buildcache-vuln | |
cache-to: type=registry,ref=${{ vars.IMAGE_NAME }}:buildcache,mode=max | |
cache-from: type=registry,ref=${{ vars.IMAGE_NAME }}:buildcache | |
env: | |
DOCKER_BUILD_RECORD_UPLOAD: false | |
# SECURITY PIPELINE | |
sec-postbuild: | |
uses: opsta/.github/.github/workflows/security-postbuild.yaml@main | |
needs: | |
- setup | |
- build-push | |
with: | |
image_name: "${{ vars.IMAGE_NAME }}:${{ needs.setup.outputs.image_tag }}" | |
secrets: | |
registry_username: ${{ github.actor }} | |
registry_password: ${{ secrets.GITHUB_TOKEN }} | |
gitops-argocd: | |
uses: opsta/.github/.github/workflows/gitops-argocd.yaml@main | |
needs: | |
- setup | |
- build-push | |
with: | |
helm_values_file: ${{ needs.setup.outputs.helm_values_file }} | |
helm_image_tag_value: ${{ needs.setup.outputs.image_tag }} | |
argocd_project: ${{ vars.ARGOCD_PROJECT }} | |
argocd_app_name: ${{ needs.setup.outputs.argocd_app_name }} | |
image_registry: ${{ vars.IMAGE_REGISTRY }} | |
image_repo: ${{ vars.IMAGE_REPO }} | |
image_tag: ${{ needs.setup.outputs.image_tag }} | |
secrets: | |
argocd_server: ${{ secrets.ARGOCD_SERVER }} | |
argocd_auth_token: ${{ secrets.ARGOCD_AUTH_TOKEN }} | |
# SECURITY PIPELINE | |
sec-postdeploy: | |
uses: opsta/.github/.github/workflows/security-postdeploy.yaml@main | |
needs: | |
- setup | |
- gitops-argocd | |
with: | |
github_repo_name: ${{ github.event.repository.name }} | |
zap_target: ${{ needs.setup.outputs.deploy_url }} | |
deploy_env: ${{ needs.setup.outputs.deploy_env }} | |
defectdojo_product_name: ${{ github.event.repository.name }} | |
secrets: | |
defectdojo_host: ${{ secrets.DEFECTDOJO_HOST }} | |
defectdojo_username: ${{ secrets.DEFECTDOJO_USERNAME }} | |
defectdojo_password: ${{ secrets.DEFECTDOJO_PASSWORD }} |