-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update flow to use different artifact registry
- Loading branch information
Showing
4 changed files
with
56 additions
and
49 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,15 +17,19 @@ on: | |
required: true | ||
type: string | ||
secrets: | ||
REGISTRY_URL: | ||
ARTIFACTORY_REGISTRY_URL: | ||
required: true | ||
REGISTRY_USER: | ||
ARTIFACTORY_AUTH2_USER: | ||
required: true | ||
REGISTRY_PASSWORD: | ||
WFI_PROVIDER: | ||
required: true | ||
COMMON_HELMCHART_NAME: | ||
WFI_SA: | ||
required: true | ||
COMMON_HELMCHART_VERSION: | ||
BASE_HELMCHART_NAME: | ||
required: true | ||
BASE_HELMCHART_VERSION: | ||
required: true | ||
PROJECT_ID: | ||
required: true | ||
APP_NAME_BASE: | ||
required: true | ||
|
@@ -36,11 +40,14 @@ env: | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | ||
jobs: | ||
build-and-test: | ||
permissions: | ||
contents: 'read' | ||
id-token: 'write' | ||
|
||
runs-on: ubuntu-latest | ||
env: | ||
ACTIONS_STEP_DEBUG: true | ||
REGISTRY_URL: ${{ secrets.REGISTRY_URL }} | ||
VALUES_FILE: ${{ inputs.values-file }} | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
@@ -66,20 +73,29 @@ jobs: | |
- name: stylelint | ||
run: yarn stylelint | ||
|
||
- name: Login to registry | ||
uses: docker/login-action@v2 | ||
- name: Authenticate to Cloud | ||
id: auth | ||
uses: 'google-github-actions/auth@v2' | ||
with: | ||
registry: ${{ secrets.REGISTRY_URL }} | ||
username: ${{ secrets.REGISTRY_USER }} | ||
password: ${{ secrets.REGISTRY_PASSWORD }} | ||
token_format: access_token | ||
project_id: ${{ secrets.PROJECT_ID }} | ||
workload_identity_provider: ${{ secrets.WFI_PROVIDER }} | ||
service_account: ${{ secrets.WFI_SA }} | ||
|
||
- name: Login to artifactory | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ secrets.ARTIFACTORY_REGISTRY_URL }} | ||
username: ${{ secrets.ARTIFACTORY_AUTH2_USER }} | ||
password: ${{ steps.auth.outputs.access_token }} | ||
|
||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
# list of Docker images to use as base name for tags | ||
images: | | ||
${{ secrets.REGISTRY_URL }}/${{ inputs.image-name }} | ||
${{ secrets.ARTIFACTORY_REGISTRY_URL }}/${{ secrets.PROJECT_ID }}/apps-docker-repo/${{ inputs.image-name }} | ||
# generate Docker tags based on the following events/attributes | ||
# This is our main tag for image in form sha-XXXXXX which we will use in helm values file (see "Preparation and Helm chart packaging" job) | ||
tags: | | ||
|
@@ -98,21 +114,6 @@ jobs: | |
# Image will be tagged with all tags from "Docker meta" step | ||
tags: ${{ steps.meta.outputs.tags }} | ||
|
||
package: | ||
needs: build-and-test | ||
runs-on: ubuntu-20.04 # Gitversion requires .NET SDK 3.1 | ||
env: | ||
ACTIONS_STEP_DEBUG: true | ||
REGISTRY_URL: ${{ secrets.REGISTRY_URL }} | ||
VALUES_FILE: ${{ inputs.values-file }} | ||
COMMON_HELMCHART_VER: ${{ secrets.COMMON_HELMCHART_VERSION }} | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
name: Code checkout | ||
with: | ||
fetch-depth: 0 | ||
|
||
# install Gitversion to obtain semver version | ||
- name: Install GitVersion | ||
uses: gittools/actions/gitversion/[email protected] | ||
|
@@ -134,11 +135,11 @@ jobs: | |
|
||
- name: Preparation and Helm chart packaging | ||
run: | | ||
echo ${{ secrets.REGISTRY_PASSWORD }} | helm registry login ${{ secrets.REGISTRY_URL }} --username ${{ secrets.REGISTRY_USER }} --password-stdin | ||
echo ${{ steps.auth.outputs.access_token }} | helm registry login ${{ secrets.ARTIFACTORY_REGISTRY_URL }} --username ${{ secrets.ARTIFACTORY_AUTH2_USER }} --password-stdin | ||
mkdir helmchart && cd ./helmchart # helm cannot untar file to the repo with the same name as a package. To avoid error we create temp folder | ||
helm pull oci://${{ secrets.REGISTRY_URL }}/helm/${{ secrets.COMMON_HELMCHART_NAME }} --version ${COMMON_HELMCHART_VER} --untar | ||
helm pull oci://${{ secrets.ARTIFACTORY_REGISTRY_URL }}/${{ secrets.PROJECT_ID }}/apps-docker-repo/helm/${{ secrets.BASE_HELMCHART_NAME }} --version ${{ secrets.BASE_HELMCHART_VERSION }} --untar | ||
echo "[INFO] Replace Docker image tag in helm chart..." | ||
sed -i -e "s/tag: latest/tag: sha-${GITVERSION_SHORTSHA}/g" ${{ secrets.COMMON_HELMCHART_NAME }}/${VALUES_FILE} | ||
sed -i -e "s/tag: latest/tag: sha-${GITVERSION_SHORTSHA}/g" ${{ secrets.BASE_HELMCHART_NAME }}/${VALUES_FILE} | ||
- name: Packaging and Uploading Helm Chart | ||
run: | | ||
|
@@ -149,8 +150,8 @@ jobs: | |
echo "[INFO] ${helm_tag}..." | ||
echo "[INFO] Replace Helm Chart package version..." | ||
sed -i -e "s/version: ${COMMON_HELMCHART_VER}/version: ${helm_tag}/g" ${{ secrets.COMMON_HELMCHART_NAME }}/Chart.yaml | ||
sed -i -e "s/version: ${{ secrets.BASE_HELMCHART_VERSION }}/version: ${helm_tag}/g" ${{ secrets.BASE_HELMCHART_NAME }}/Chart.yaml | ||
echo "[INFO] Changing Helm Chart package name..." | ||
sed -i -e "s/name: ${{ secrets.COMMON_HELMCHART_NAME }}/name: ${{ secrets.APP_NAME_BASE }}/g" ${{ secrets.COMMON_HELMCHART_NAME }}/Chart.yaml | ||
helm package ${{ secrets.COMMON_HELMCHART_NAME }} | ||
helm push ${{ secrets.APP_NAME_BASE }}-${helm_tag}.tgz oci://${{ secrets.REGISTRY_URL }}/helm | ||
sed -i -e "s/name: ${{ secrets.BASE_HELMCHART_NAME }}/name: ${{ secrets.APP_NAME_BASE }}/g" ${{ secrets.BASE_HELMCHART_NAME }}/Chart.yaml | ||
helm package ${{ secrets.BASE_HELMCHART_NAME }} | ||
helm push ${{ secrets.APP_NAME_BASE }}-${helm_tag}.tgz oci://${{ secrets.ARTIFACTORY_REGISTRY_URL }}/${{ secrets.PROJECT_ID }}/apps-docker-repo/helm |
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
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
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