From 0af3cf079f9e0d32318b25778c074d5d5c80c8e2 Mon Sep 17 00:00:00 2001 From: lavanya150598 <91895179+lavanya150598@users.noreply.github.com> Date: Tue, 24 Sep 2024 19:06:40 +0530 Subject: [PATCH 1/2] Create dynamic-vars-tasks.yml --- .github/workflows/dynamic-vars-tasks.yml | 25 ++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/dynamic-vars-tasks.yml diff --git a/.github/workflows/dynamic-vars-tasks.yml b/.github/workflows/dynamic-vars-tasks.yml new file mode 100644 index 00000000..375868de --- /dev/null +++ b/.github/workflows/dynamic-vars-tasks.yml @@ -0,0 +1,25 @@ +name: Dynamic Vars Tasks + +on: + workflow_dispatch: + inputs: + SNAPSHOT_BUILD_VERSION: + description: 'Snapshot build version' + required: true + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Set snapshot build version + run: | + echo "SNAPSHOT_BUILD_VERSION=${SNAPSHOT_BUILD_VERSION}" >> $GITHUB_ENV + - name: Build and deploy + run: | + # Your build and deploy commands go here + # For example: + # npm install + # npm run build + # npm run deploy From 614772fb689a0c17cc08954f6d8465ebc91f8bf8 Mon Sep 17 00:00:00 2001 From: lavanya150598 <91895179+lavanya150598@users.noreply.github.com> Date: Wed, 25 Sep 2024 10:24:43 +0530 Subject: [PATCH 2/2] Update dynamic-vars-tasks.yml by lavanya --- .github/workflows/dynamic-vars-tasks.yml | 67 +++++++++++++++++++++--- 1 file changed, 59 insertions(+), 8 deletions(-) diff --git a/.github/workflows/dynamic-vars-tasks.yml b/.github/workflows/dynamic-vars-tasks.yml index 375868de..b5053990 100644 --- a/.github/workflows/dynamic-vars-tasks.yml +++ b/.github/workflows/dynamic-vars-tasks.yml @@ -13,13 +13,64 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v2 - - name: Set snapshot build version + + - name: Set up Java + uses: actions/setup-java@v1 + with: + java-version: '11' + + - name: Create branch + run: | + git checkout -b dynamic-vars-tasks + + - name: Update pom.xml with snapshot build version run: | - echo "SNAPSHOT_BUILD_VERSION=${SNAPSHOT_BUILD_VERSION}" >> $GITHUB_ENV - - name: Build and deploy + sed -i "s/.*<\/version>/${SNAPSHOT_BUILD_VERSION}<\/version>/" pom.xml + + - name: Build run: | - # Your build and deploy commands go here - # For example: - # npm install - # npm run build - # npm run deploy + mvn clean package -Dmaven.test.skip=true + + - name: Commit changes + run: | + git add . + git commit -m "Update pom.xml with snapshot build version ${SNAPSHOT_BUILD_VERSION}" + + - name: Push changes to branch + uses: ad-m/github-push-action@v0.5.1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + force: true + + - name: Create PR + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + github.pulls.create({ + owner: context.repo.owner, + repo: context.repo.repo, + title: 'Update pom.xml with snapshot build version ${SNAPSHOT_BUILD_VERSION}', + head: 'dynamic-vars-tasks', + base: 'main', + body: 'Automatically generated PR' + }) + + - name: CodeQL scanning + uses: github/codeql-action/analyze@v2 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + languages: java + + - name: Merge PR + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + github.pulls.merge({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: github.context.pullRequest.number, + commit_title: 'Merge PR', + commit_message: 'Automatically merged PR' + })