Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 0 additions & 65 deletions .github/workflows/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,71 +54,6 @@ jobs:
uses: mikefarah/yq@v4.30.8
with:
cmd: yq ".schemaVersion" ${{ inputs.configurationFilepath }}
# Deprecated
deployment_legacy:
runs-on: ${{ inputs.runner }}
needs: [read_schema_version]
if: needs.read_schema_version.outputs.version != 'v2'
steps:
- name: Checkout current git repository
uses: actions/checkout@v3
- name: Load plconfig deployment values
id: deployment-yaml
uses: mikefarah/yq@v4.30.8
with:
cmd: yq -o json -I 0 '.deployment' ${{ inputs.configurationFilepath }}
- name: Load k8s deployment variables
id: k8s
run: |
# shellcheck disable=SC2129,SC2086
echo "namespace=${{ fromJSON(steps.deployment-yaml.outputs.result).namespace }}" >> $GITHUB_OUTPUT
# shellcheck disable=SC2086
echo "chart=${{ fromJSON(steps.deployment-yaml.outputs.result).chart }}" >> $GITHUB_OUTPUT
# shellcheck disable=SC2086
echo "containerContextPath=${{ fromJSON(steps.deployment-yaml.outputs.result).container.contextPath || '.' }}" >> $GITHUB_OUTPUT
# shellcheck disable=SC2086
echo "containerFile=${{ fromJSON(steps.deployment-yaml.outputs.result).container.file || 'Containerfile' }}" >> $GITHUB_OUTPUT
if [[ "${{ inputs.env }}" == 'prod' ]]
then
URL="${{ fromJSON(steps.deployment-yaml.outputs.result).urls.prod[0] }}"
STATUS_URL="${{ fromJSON(steps.deployment-yaml.outputs.result).status_url.prod }}"
elif [[ "${{ inputs.env }}" == 'staging' ]]
then
URL="${{ fromJSON(steps.deployment-yaml.outputs.result).urls.staging[0] }}"
STATUS_URL="${{ fromJSON(steps.deployment-yaml.outputs.result).status_url.staging }}"
else
URL="${{ fromJSON(steps.deployment-yaml.outputs.result).urls.test[0] }}"
STATUS_URL="${{ fromJSON(steps.deployment-yaml.outputs.result).status_url.test }}"
fi
# shellcheck disable=SC2086
echo "url=$URL" >> $GITHUB_OUTPUT
# shellcheck disable=SC2086
echo "status-url=$STATUS_URL" >> $GITHUB_OUTPUT
- name: Create Github ${{ fromJSON(steps.deployment-yaml.outputs.result).name }} k8s deployment
uses: chrnorm/deployment-action@v2
with:
auto-merge: false
environment: ${{ inputs.env }}
ref: ${{ inputs.ref }}
required-contexts: ""
payload: |
{
"author": ${{ toJSON(inputs.author) }},
"chart": ${{ toJSON(steps.k8s.outputs.chart) }},
"container": {
"context": ${{ toJSON(steps.k8s.outputs.containerContextPath) }},
"file": ${{ toJSON(steps.k8s.outputs.containerFile) }}
},
"description": ${{ toJSON(inputs.description) }},
"env": ${{ toJSON(inputs.env) }},
"name": ${{ toJSON(fromJSON(steps.deployment-yaml.outputs.result).name) }},
"namespace": ${{ toJSON(steps.k8s.outputs.namespace) }},
"statusUrl": ${{ toJSON(steps.k8s.outputs.status-url) }},
"url": ${{ toJSON(steps.k8s.outputs.url) }}
}
production-environment: "${{ inputs.env == 'prod' }}"
transient-environment: "${{ inputs.env == 'test' }}"
token: ${{ secrets.repoAccessToken }}
detect_declarations:
runs-on: ${{ inputs.runner }}
needs: [read_schema_version]
Expand Down
23 changes: 16 additions & 7 deletions .github/workflows/kubernetes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ on:
description: The email of the bot that will appear in the GitOps commit
default: dev.bot@parcellab.com
type: string
chartInAppRepo:
required: false
description: Specify if chart is migrated into the application's repository
default: false
type: boolean
deploymentRepoPath:
required: false
description: The path within the deployment repository that holds all version files
Expand Down Expand Up @@ -205,22 +210,26 @@ jobs:
path: remote
token: ${{ secrets.repoAccessToken }}
ref: main
# Legacy
- if: github.event.deployment.payload.schemaVersion != 'v2'
- if: github.event.deployment.payload.schemaVersion == 'v2' && github.event.deployment.payload.env != 'playground' && inputs.chartInAppRepo == false
name: Update ${{ github.event.deployment.payload.name }} version for ${{ github.event.deployment.environment }} values
uses: mikefarah/yq@v4.30.8
with:
cmd: yq '(.${{ github.event.deployment.payload.chart }}.image.tag = "${{ needs.initialize.outputs.version }}")' -i remote/${{ inputs.deploymentRepoPath }}/${{ github.event.deployment.payload.namespace }}/${{ github.event.deployment.payload.env }}/${{ github.event.deployment.payload.name }}/${{ inputs.versionFilePath }}
- if: github.event.deployment.payload.schemaVersion == 'v2' && github.event.deployment.payload.env != 'playground'
name: Update ${{ github.event.deployment.payload.name }} version for ${{ github.event.deployment.environment }} values
cmd: yq '(.${{ github.event.deployment.payload.kubernetes.versionKey }} = "${{ needs.initialize.outputs.version }}")' -i remote/${{ inputs.deploymentRepoPath }}/${{ github.event.deployment.payload.kubernetes.namespace }}/${{ github.event.deployment.payload.env }}/${{ github.event.deployment.payload.name }}/${{ inputs.versionFilePath }}
- if: github.event.deployment.payload.schemaVersion == 'v2' && github.event.deployment.payload.env != 'playground' && inputs.chartInAppRepo == true
name: Deploy ${{ github.sha }} to ${{ github.event.deployment.environment }} values
uses: mikefarah/yq@v4.30.8
with:
cmd: yq '(.${{ github.event.deployment.payload.kubernetes.versionKey }} = "${{ needs.initialize.outputs.version }}")' -i remote/${{ inputs.deploymentRepoPath }}/${{ github.event.deployment.payload.kubernetes.namespace }}/${{ github.event.deployment.payload.env }}/${{ github.event.deployment.payload.name }}/${{ inputs.versionFilePath }}
- if: github.event.deployment.payload.schemaVersion == 'v2' && github.event.deployment.payload.env == 'playground'
cmd: yq '(.${{ github.event.deployment.payload.kubernetes.versionKey }} = "${{ needs.initialize.outputs.version }}")' -i remote/${{ inputs.deploymentRepoPath }}/values.${{ github.event.deployment.payload.env }}.yaml
- if: github.event.deployment.payload.schemaVersion == 'v2' && github.event.deployment.payload.env == 'playground' && inputs.chartInAppRepo == false
name: Update ${{ github.event.deployment.payload.name }} version for ${{ github.event.deployment.environment }} values
uses: mikefarah/yq@v4.30.8
with:
cmd: yq '(.${{ github.event.deployment.payload.kubernetes.versionKey }} = "${{ needs.initialize.outputs.version }}")' -i remote/${{ inputs.deploymentRepoPath }}/${{ github.event.deployment.payload.kubernetes.namespace }}/prod/${{ github.event.deployment.payload.name }}/values.playground.yaml
- if: github.event.deployment.payload.schemaVersion == 'v2' && github.event.deployment.payload.env == 'playground' && inputs.chartInAppRepo == true
name: Deploy ${{ github.sha }} to ${{ github.event.deployment.environment }} values
uses: mikefarah/yq@v4.30.8
with:
cmd: yq '(.${{ github.event.deployment.payload.kubernetes.versionKey }} = "${{ needs.initialize.outputs.version }}")' -i remote/${{ inputs.deploymentRepoPath }}/values.playground.yaml
- name: Commit deployment file
run: |
cd remote
Expand Down
61 changes: 0 additions & 61 deletions .github/workflows/plconfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,67 +49,6 @@ jobs:
uses: mikefarah/yq@v4.30.8
with:
cmd: yq ".schemaVersion" ${{ inputs.configurationFilepath }}
plconfig_legacy:
if: needs.read_schema_version.outputs.version != 'v2'
runs-on: ${{ inputs.runner }}
needs: [read_schema_version]
steps:
- name: Checkout current git repository
uses: actions/checkout@v3
- name: Load name
id: name
uses: mikefarah/yq@v4.30.8
with:
cmd: yq ".deployment.name" ${{ inputs.configurationFilepath }}
- name: Load namespace
id: namespace
uses: mikefarah/yq@v4.30.8
with:
cmd: yq ".deployment.namespace" ${{ inputs.configurationFilepath }}
- name: Load chart
id: chart
uses: mikefarah/yq@v4.30.8
with:
cmd: yq ".deployment.chart" ${{ inputs.configurationFilepath }}
- name: Checkout ${{ inputs.deploymentRepoURL }} git repository
uses: actions/checkout@v3
with:
repository: ${{ inputs.deploymentRepoURL }}
path: remote
token: ${{ secrets.repoAccessToken }}
ref: main
- name: Load vars
id: vars
run: |
# shellcheck disable=SC2086
echo "namespace-path=remote/${{ inputs.deploymentRepoPath }}/${{ steps.namespace.outputs.result }}" >> $GITHUB_OUTPUT
# shellcheck disable=SC2086
echo "do-not-edit=DO NOT EDIT. Auto generated from ${{ steps.name.outputs.result }} ${{ inputs.configurationFilepath }} (replaces values.yaml instead)" >> $GITHUB_OUTPUT
# Load plconfig values scoping to a subchart
- name: Load external values for all environments
uses: mikefarah/yq@v4.30.8
with:
cmd: >-
$(yq '.deployment.values | has("dev")' ${{ inputs.configurationFilepath }}) == 'true' && yq '{ "${{ steps.chart.outputs.result }}": .deployment.values.dev } | . head_comment="${{ steps.vars.outputs.do-not-edit }}"' ${{ inputs.configurationFilepath }} > ${{ steps.vars.outputs.namespace-path }}/dev/${{ steps.name.outputs.result }}/values-external.yaml ||
$(yq '.deployment.values | has("prod")' ${{ inputs.configurationFilepath }}) == 'true' && yq '{ "${{ steps.chart.outputs.result }}": .deployment.values.prod } | . head_comment="${{ steps.vars.outputs.do-not-edit }}"' ${{ inputs.configurationFilepath }} > ${{ steps.vars.outputs.namespace-path }}/prod/${{ steps.name.outputs.result }}/values-external.yaml ||
$(yq '.deployment.values | has("staging")' ${{ inputs.configurationFilepath }}) == 'true' && yq '{ "${{ steps.chart.outputs.result }}": .deployment.values.staging } | . head_comment="${{ steps.vars.outputs.do-not-edit }}"' ${{ inputs.configurationFilepath }} > ${{ steps.vars.outputs.namespace-path }}/staging/${{ steps.name.outputs.result }}/values-external.yaml ||
$(yq '.deployment.values | has("test")' ${{ inputs.configurationFilepath }}) == 'true' && yq '{ "${{ steps.chart.outputs.result }}": .deployment.values.test } | . head_comment="${{ steps.vars.outputs.do-not-edit }}"' ${{ inputs.configurationFilepath }} > ${{ steps.vars.outputs.namespace-path }}/test/${{ steps.name.outputs.result }}/values-external.yaml || true
# Commit & Push
- name: Commit deployment files
run: |
cd remote
git config --global user.email "${{ inputs.botEmail }}"
git config --global user.name "${{ inputs.botName }}"
git add .
git commit --allow-empty -m "chore(${{ steps.name.outputs.result }}): set parcelLab config values"
- name: Push changes to main in ${{ inputs.deploymentRepoURL }} git repository
uses: ad-m/github-push-action@0fafdd62b84042d49ec0cb92d9cac7f7ce4ec79e
with:
repository: ${{ inputs.deploymentRepoURL }}
directory: remote
github_token: ${{ secrets.repoAccessToken }}
branch: main
force: true
detect_declarations:
if: needs.read_schema_version.outputs.version == 'v2'
runs-on: ${{ inputs.runner }}
Expand Down