|
| 1 | +name: CI/CD Workflow |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - release/* |
| 8 | + tags: |
| 9 | + - "[0-9]+.[0-9]+.[0-9]+" |
| 10 | + - "[0-9]+.[0-9]+" |
| 11 | + |
| 12 | +permissions: |
| 13 | + id-token: write |
| 14 | + contents: write |
| 15 | + pull-requests: write |
| 16 | + |
| 17 | +jobs: |
| 18 | + generate-version: |
| 19 | + runs-on: ubuntu-latest |
| 20 | + outputs: |
| 21 | + NEW_VERSION: ${{ steps.generate_new_version.outputs.NEW_VERSION }} |
| 22 | + steps: |
| 23 | + - name: Checkout repository |
| 24 | + uses: actions/checkout@v2 |
| 25 | + - name: Extract short SHA |
| 26 | + id: vars |
| 27 | + run: echo "SHA_SHORT=$(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_ENV |
| 28 | + - name: generate new version |
| 29 | + id: generate_new_version |
| 30 | + run: | |
| 31 | + APP_VERSION=$(jq -r .version version.json) |
| 32 | + echo "BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT |
| 33 | + if [[ "$GITHUB_REF_NAME" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then |
| 34 | + NEW_VERSION="${GITHUB_REF_NAME}" |
| 35 | + else |
| 36 | + NEW_VERSION=$(echo "$APP_VERSION-${{github.run_number}}-${SHA_SHORT}") |
| 37 | + fi |
| 38 | + echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV |
| 39 | + echo "::set-output name=NEW_VERSION::$NEW_VERSION" |
| 40 | +
|
| 41 | + - name: Check NEW_VERSION |
| 42 | + run: echo "NEW_VERSION is ${{ steps.generate_new_version.outputs.NEW_VERSION }} on branch ${{ steps.generate_new_version.outputs.branch }}" |
| 43 | + |
| 44 | + docker-build-and-push: |
| 45 | + uses: Biolevate/biolevops-workflows/.github/workflows/docker-build-push.yml@main |
| 46 | + with: |
| 47 | + GITHUB_SHA: "${{ github.sha }}" |
| 48 | + REPOSITORY_NAME: "processor-forge" |
| 49 | + REPOSITORIES: "processor-forge,py-standards" |
| 50 | + secrets: inherit |
| 51 | + |
| 52 | + helm-build-and-push: |
| 53 | + uses: Biolevate/biolevops-workflows/.github/workflows/helm-build-push.yml@main |
| 54 | + with: |
| 55 | + GITHUB_SHA: "${{ github.sha }}" |
| 56 | + REPOSITORY_NAME: "processor-forge" |
| 57 | + secrets: inherit |
| 58 | + |
| 59 | + helm-deploy: |
| 60 | + needs: |
| 61 | + - generate-version |
| 62 | + - helm-build-and-push |
| 63 | + - docker-build-and-push |
| 64 | + uses: Biolevate/biolevops-workflows/.github/workflows/helm-deploy.yml@main |
| 65 | + with: |
| 66 | + REPOSITORY_NAME: "processor-forge" |
| 67 | + NEW_VERSION: ${{ needs.generate-version.outputs.NEW_VERSION }} |
| 68 | + secrets: inherit |
| 69 | + |
| 70 | + manage-version: |
| 71 | + needs: |
| 72 | + - generate-version |
| 73 | + - helm-build-and-push |
| 74 | + - docker-build-and-push |
| 75 | + uses: Biolevate/biolevops-workflows/.github/workflows/version.yml@main |
| 76 | + with: |
| 77 | + APPLICATION: "processor-forge" |
| 78 | + NEW_VERSION: "${{ needs.generate-version.outputs.NEW_VERSION }}" |
| 79 | + |
| 80 | + notify-slack-on-error: |
| 81 | + needs: |
| 82 | + - generate-version |
| 83 | + - helm-build-and-push |
| 84 | + - helm-deploy |
| 85 | + - docker-build-and-push |
| 86 | + if: failure() |
| 87 | + uses: Biolevate/biolevops-workflows/.github/workflows/notify-slack.yml@main |
| 88 | + with: |
| 89 | + CHANNEL: "tech-team" |
| 90 | + TITLE: "🚨 Le build *processor-forge* a échoué ! 🚨" |
| 91 | + TEXT: "Détails du build : <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}>|Cliquez ici pour voir> <!channel> @devs" |
| 92 | + COLOR: "danger" |
0 commit comments