|
2 | 2 | name: Publish Checkmarx One CLI GitHub Action |
3 | 3 |
|
4 | 4 | on: |
5 | | - push: |
6 | | - tags: |
7 | | - - '*' |
| 5 | + workflow_call: |
| 6 | + inputs: |
| 7 | + tag: |
| 8 | + description: 'Next release tag' |
| 9 | + required: true |
8 | 10 |
|
9 | 11 | jobs: |
10 | 12 | release: |
11 | 13 | runs-on: ubuntu-latest |
| 14 | + outputs: |
| 15 | + CLI_VERSION: ${{ steps.extract_cli_version.outputs.CLI_VERSION }} |
| 16 | + |
12 | 17 | steps: |
13 | | - |
| 18 | + - name: Checkout |
| 19 | + |
| 20 | + with: |
| 21 | + token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} |
| 22 | + |
| 23 | + - name: Extract CLI version from Dockerfile |
| 24 | + id: extract_cli_version |
| 25 | + run: | |
| 26 | + IMAGE_LINE=$(grep -m 1 '^FROM' Dockerfile) |
| 27 | + CLI_VERSION=$(echo "$IMAGE_LINE" | awk -F':' '{print $2}') |
| 28 | +
|
| 29 | + echo "Extracted CLI version: $CLI_VERSION" |
| 30 | +
|
| 31 | + echo "CLI_VERSION=$CLI_VERSION" >> $GITHUB_ENV |
| 32 | + echo "::set-output name=CLI_VERSION::$CLI_VERSION" |
| 33 | +
|
| 34 | + - name: Tag |
| 35 | + run: | |
| 36 | + echo ${{ github.event.inputs.tag }} |
| 37 | + echo "NEXT_VERSION=${{ github.event.inputs.tag }}" >> $GITHUB_ENV |
| 38 | + tag=${{ github.event.inputs.tag }} |
| 39 | + message='${{ github.event.inputs.tag }}: PR #${{ github.event.pull_request.number }} ${{ github.event.pull_request.title }}' |
| 40 | + git config user.name "${GITHUB_ACTOR}" |
| 41 | + git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" |
| 42 | + git tag -a "${tag}" -m "${message}" |
| 43 | + git push origin "${tag}" |
| 44 | +
|
14 | 45 | - name: Create Release |
15 | 46 | uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 #v1 |
16 | 47 | with: |
17 | | - tag_name: ${{ github.ref_name }} |
| 48 | + tag_name: ${{ github.event.inputs.tag }} |
18 | 49 | generate_release_notes: true |
19 | 50 |
|
20 | 51 | notify: |
21 | | - runs-on: ubuntu-latest |
22 | | - needs: release |
23 | | - steps: |
24 | | - - name: Get latest relase notes |
25 | | - id: release |
26 | | - env: |
27 | | - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
28 | | - run: | |
29 | | - body_release="$(gh api -H "Accept: application/vnd.github.v3+json" /repos/Checkmarx/ast-github-action/releases/latest | jq -r '.body' )" |
30 | | - body_release="${body_release//$'\n'/'%0A'}" |
31 | | - echo "::set-output name=body_release::$body_release" |
32 | | - - name: Converts Markdown to HTML |
33 | | - id: convert |
34 | | - uses: lifepal/markdown-to-html@253bbd85fbdeafe2d1f18c1b9289be24e5cf8f8f #v1.2 |
35 | | - with: |
36 | | - text: "${{ steps.release.outputs.body_release }}" |
37 | | - |
38 | | - - name: Clean html |
39 | | - id: clean |
40 | | - run: | |
41 | | - clean="$(echo "${{ steps.convert.outputs.html }}" | awk '{gsub(/id=.[a-z]+/,"");print}' | tr -d '\n')" |
42 | | - echo "$clean" |
43 | | - echo "::set-output name=clean::$clean" |
44 | | - - name: Send a Notification |
45 | | - id: notify |
46 | | - uses: thechetantalwar/teams-notify@8a78811f5e8f58cdd204efebd79158006428c46b #v2 |
47 | | - with: |
48 | | - teams_webhook_url: ${{ secrets.TEAMS_WEBHOOK_URI }} |
49 | | - message: "<h1>Checkmarx One Github Action ${{ github.ref_name }}</h1>${{ steps.clean.outputs.clean }}" |
| 52 | + needs: release |
| 53 | + uses: Checkmarx/plugins-release-workflow/.github/workflows/release-notify.yml@main |
| 54 | + with: |
| 55 | + product_name: Github Action |
| 56 | + release_version: ${{ github.event.inputs.tag }} |
| 57 | + cli_release_version: ${{ needs.release.outputs.CLI_VERSION }} |
| 58 | + release_author: "Phoenix Team" |
| 59 | + release_url: https://github.com/Checkmarx/ast-github-action/releases/tag/${{ github.event.inputs.tag }} |
| 60 | + jira_product_name: GITHUB_ACTION |
| 61 | + secrets: inherit |
0 commit comments