forked from TietoEVRY-DataPlatforms/gitops-deploy-tag-action
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Intial commit - working implementation
- Loading branch information
0 parents
commit 3d64c81
Showing
4 changed files
with
158 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Compiled class file | ||
*.class | ||
|
||
# Log file | ||
*.log | ||
logs/ | ||
|
||
# Package Files # | ||
*.war | ||
*.nar | ||
*.ear | ||
*.zip | ||
*.tar.gz | ||
*.rar | ||
|
||
# IDEA files | ||
.idea/* | ||
*.ipr | ||
*.iml | ||
*.iws | ||
!.idea/checkstyle-idea.xml | ||
|
||
# Maven target folder | ||
**/target/* | ||
|
||
# Payara Micro | ||
payara/ | ||
|
||
# MacOS files | ||
.DS_Store | ||
|
||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | ||
hs_err_pid* | ||
|
||
# VSCode java | ||
*.vscode | ||
*.classpath | ||
*.settings | ||
.project | ||
|
||
ftp_volume | ||
|
||
/http-requests-examples/http-client.private.env.json | ||
all-customers* | ||
|
||
load-test/config.csv | ||
load-test/*.log | ||
load-test/target | ||
load-test/fjellinjen-agreements.csv | ||
|
||
e2e/run-* | ||
cluster/db-data | ||
/src/test/resources/tools.properties | ||
tmp |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2021 lwitkowski | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# GitHub Action to update image tag in target Helm values.yaml | ||
|
||
This [GitHub Action](https://github.com/actions) checks out target repo, updates image tag in specified target file and pushes the changes. | ||
|
||
You can add this action to your GitHub workflow for Ubuntu runners (e.g. `runs-on: ubuntu-latest`) as follows: | ||
|
||
```yaml | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
env: | ||
DEPLOY_GITOPS_REPO: 'lwitkowski/playground-gitops' | ||
DEPLOY_TOKEN: ${{ secrets.DEPLOY_TOKEN }} | ||
|
||
steps: | ||
- name: Deploy to test | ||
uses: lwitkowski/gitops-deploy-tag-action@master | ||
with: | ||
target-file: 'sample-service/test/values.yaml' | ||
|
||
- name: Deploy to production | ||
uses: lwitkowski/gitops-deploy-tag-action@master | ||
with: | ||
target-file: 'sample-service/prod/values.yaml' | ||
``` | ||
## Configuration | ||
The action can be configured by the following options. | ||
|Option|Default Value|Description| | ||
|:-----|:-----:|:----------| | ||
|`gitops-repo`|`${DEPLOY_GITOPS_REPO}`|Owner and name of target gitops repository name where yaml file is stored. | | ||
|`target-file`|mandatory|Path to yaml file inside gitops repo to be updated.| | ||
|`docker-image-tag`|`${GITHUB_SHA::6}`|Docker image tag to be set in target yaml file.| | ||
|`env.DEPLOY_TOKEN`|mandatory|Github access token with write permission to gitops repo. Should be set as env variable in calling workflow.| | ||
|
||
|
||
Note: Running this action on `pull_request_target` events is [dangerous if combined with code checkout and code execution](https://securitylab.github.com/research/github-actions-preventing-pwn-requests). |
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: 'GitOps Deploy Tag Action' | ||
description: 'Updates image tag in target file' | ||
inputs: | ||
gitops-repo: | ||
description: 'gitops repo to be updated' | ||
required: true | ||
default: ${DEPLOY_GITOPS_REPO} | ||
|
||
target-file: | ||
description: 'Target yaml file to replace tag' | ||
required: true | ||
|
||
docker-image-tag: | ||
description: 'docker image tag' | ||
required: true | ||
default: ${GITHUB_SHA::6} | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Checkout gitops | ||
run: | | ||
echo Checking out https://github.com/${{ inputs.gitops-repo }}.git | ||
rm -rf ./gitops_tmp | ||
git clone --depth 1 https://x-access-token:$DEPLOY_TOKEN@github.com/${{ inputs.gitops-repo }}.git ./gitops_tmp | ||
shell: bash | ||
|
||
- name: Update image tag | ||
working-directory: ./gitops_tmp | ||
run: | | ||
echo Setting \"${{ inputs.docker-image-tag }}\" tag in "${{ inputs.target-file }}" | ||
sed -i 's/tag: .*$/tag: "'${{ inputs.docker-image-tag }}'"/g' ${{ inputs.target-file }} | ||
shell: bash | ||
|
||
- name: Push changes to gitops | ||
working-directory: ./gitops_tmp | ||
run: | | ||
echo Pushing changes to ${{ inputs.gitops-repo }} | ||
git config user.email "ga-deployer@tietoevry.com" | ||
git config user.name "GA deployer" | ||
git add . | ||
git commit --allow-empty -m "Deploy \"${{ inputs.docker-image-tag }}\" tag for ${{ inputs.target-file }}" | ||
git push -u origin master | ||
shell: bash |