Skip to content

fix: bug of ex-client-trace-id not cleared in the end #88

fix: bug of ex-client-trace-id not cleared in the end

fix: bug of ex-client-trace-id not cleared in the end #88

Workflow file for this run

---
name: Stage
on:
pull_request_target:
types:
- closed
branches:
- main
paths:
- "src/main/**"
- "pom.xml"
- ".github/workflows/**"
jobs:
deploy:
runs-on: ubuntu-latest
name: Deploy snapshot
env:
RUN_PYTHON_BIN: ${{ vars.RUN_PYTHON_BIN }}
if: github.repository_owner == 'RHEcosystemAppEng' && github.event.pull_request.merged == true && !startsWith(github.head_ref, 'release/')
outputs:
project_version: ${{ steps.project.outputs.version }}
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Setup Java 11
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 11
cache: maven
- name: Get pom specs
id: project
run: |
echo "version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> "$GITHUB_OUTPUT"
- name: Deploy snapshot to GitHub
if: |
contains(steps.project.outputs.version, 'SNAPSHOT') &&
github.repository == 'RHEcosystemAppEng/exhort-java-api'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: mvn deploy -Pprepare-deployment,deploy-github -B -ff -DskipTests=true -Dskip.junit_platform=true
release:
runs-on: ubuntu-latest
name: Release snapshot
environment: staging
needs: deploy
if: |
contains(needs.deploy.outputs.project_version, 'SNAPSHOT') &&
github.repository_owner == 'RHEcosystemAppEng' && github.event.pull_request.merged == true && !startsWith(github.head_ref, 'release/')
steps:
- name: Check for existing ${{ needs.deploy.outputs.project_version }} release
id: existing_release
uses: actions/github-script@v6
continue-on-error: true
with:
github-token: ${{ secrets.STAGING_PAT }}
script: |
const repo_name = context.payload.repository.full_name
var response = await github.request('GET /repos/' + repo_name + '/releases/tags/${{ needs.deploy.outputs.project_version }}')
// if the request fails (ie 404) the next steps will not occur and the output will not be set
core.setOutput('id', response.data.id)
- name: Checkout sources
uses: actions/checkout@v3
- name: Delete ${{ needs.deploy.outputs.project_version }} release if exists
if: ${{ steps.existing_release.outputs.id }}
uses: actions/github-script@v6
with:
github-token: ${{ secrets.STAGING_PAT }}
script: |
const repo_name = context.payload.repository.full_name
await github.request('DELETE /repos/' + repo_name + '/releases/' + ${{ steps.existing_release.outputs.id }})
- name: Delete ${{ needs.deploy.outputs.project_version }} tag if exists
continue-on-error: true
run: git push --delete origin ${{ needs.deploy.outputs.project_version }}
# a little pause between deleting the release and creating a new one
# without it, the new release might be a weird release, i.e. a draft release
- name: Sleep 5
run: sleep 5
- name: Create new ${{ needs.deploy.outputs.project_version }} release
uses: actions/github-script@v6
with:
github-token: ${{ secrets.STAGING_PAT }}
script: |
const repo_name = context.payload.repository.full_name
const response = await github.request('POST /repos/' + repo_name + '/releases', {
tag_name: '${{ needs.deploy.outputs.project_version }}',
name: '${{ needs.deploy.outputs.project_version }}',
draft: false,
prerelease: true,
generate_release_notes: true,
make_latest: 'false'
})