Feature/306 check in refactoring #109
Workflow file for this run
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: 'Staging-Deploy' | |
on: | |
pull_request: | |
types: | |
- closed | |
branches: [ main ] | |
jobs: | |
staging-okr-deploy: | |
if: github.event.pull_request.merged == true | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout project | |
uses: actions/checkout@v2 | |
with: | |
token: ${{secrets.VERSION_TOKEN}} | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v2 | |
with: | |
java-version: '17' | |
distribution: 'adopt' | |
server-id: github | |
settings-path: ${{github.workspace}} | |
- name: Generate and Set New Version | |
run: mvn build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.nextIncrementalVersion} -DgenerateBackupPoms=false | |
- name: Extract Maven project version | |
run: echo "version=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)" >> $GITHUB_OUTPUT | |
id: store-version | |
- name: Set New Snapshot Version | |
run: mvn build-helper:parse-version versions:set -DnewVersion=${{ steps.store-version.outputs.version}}-SNAPSHOT -DgenerateBackupPoms=false | |
- name: Commit and Push Changes | |
shell: bash | |
env: | |
COMMITPREFIX: '[VU]' | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "GitHub Actions" | |
git add . || { | |
echo "No files were changed, so we did not commit anything" | |
exit 1 | |
} | |
git commit -m "$COMMITPREFIX Automated version update" || { | |
echo "No changes to commit, skipping push" | |
exit 0 | |
} | |
git push -f origin main | |
- name: Set up node 18 | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18.17.1 | |
- name: Install Dependencies | |
run: cd ./frontend && npm ci | |
- name: Build frontend with Angular | |
run: cd ./frontend && npm run build:staging | |
- name: Build backend with Maven | |
run: mvn -B clean package --file pom.xml -P staging | |
- name: Log in to Quay registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{ secrets.QUAY_REGISTRY }} | |
username: ${{ secrets.QUAY_USERNAME }} | |
password: ${{ secrets.QUAY_TOKEN }} | |
- name: Build and push the docker image | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
file: docker/Dockerfile | |
push: true | |
tags: ${{ secrets.TAG }}:${{ steps.store-version.outputs.version}}-STAGING | |
- name: Trigger Deployment Workflow with latest Version | |
uses: actions/checkout@v3 | |
with: | |
repository: ${{ vars.TARGET_REPOSITORY }} | |
ref: ${{ vars.TARGET_REFERENCE }} | |
path: ccy-repo | |
token: ${{secrets.VERSION_TOKEN}} | |
- name: Change Yaml | |
shell: bash | |
env: | |
FILEPATH: ${{ vars.FILEPATH }} | |
YAMLPATH: ${{ vars.YAML_PATH }} | |
NEWVALUE: ${{ vars.NEW_VALUE_URL }}:${{ steps.store-version.outputs.version}}-STAGING | |
VERSION: v4.25.2 | |
BINARY: yq_linux_amd64 | |
run: | | |
wget -q https://github.com/mikefarah/yq/releases/download/${VERSION}/${BINARY}.tar.gz -O - |\ | |
tar xz && mv ${BINARY} /usr/local/bin/yq | |
yq -i "${YAMLPATH} = \"${NEWVALUE}\"" ccy-repo/${FILEPATH} | |
- name: Commit and Push Changes | |
working-directory: ccy-repo | |
shell: bash | |
env: | |
COMMITPREFIX: '[CTS]' | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "GitHub Actions" | |
git add ${{ vars.FILEPATH }} || { | |
echo "No files were changed, so we did not commit anything" | |
exit 1 | |
} && \ | |
git commit -m "$COMMITPREFIX Automated changes to ${{ vars.FILEPATH }}" && \ | |
git push origin ${{ vars.TARGET_REFERENCE }} | |
- run: rm -rf ccy-repo | |
shell: bash |