|
| 1 | +on: |
| 2 | + pull_request: |
| 3 | + types: [closed] |
| 4 | + branches: |
| 5 | + - master |
| 6 | + |
| 7 | +env: |
| 8 | + ENGINE_VERSION: ${{ vars.ENGINE_VERSION }} |
| 9 | + PLATFORM: "LINUX_X64" |
| 10 | + ENGINE: "2ms" |
| 11 | + CES_ENVIROMENT: "prod" |
| 12 | + |
| 13 | +jobs: |
| 14 | + ci-projects: |
| 15 | + if: github.event.pull_request.merged == true |
| 16 | + runs-on: ubuntu-latest |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 |
| 19 | + with: |
| 20 | + ref: ${{ github.event.pull_request.head.sha }} |
| 21 | + |
| 22 | + - uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 |
| 23 | + with: |
| 24 | + go-version: "^1.22" |
| 25 | + |
| 26 | + - uses: actions/checkout@v4 |
| 27 | + with: |
| 28 | + repository: Checkmarx-CxSast/2ms-internal |
| 29 | + path: 2ms |
| 30 | + |
| 31 | + - name: Build 2ms Binary |
| 32 | + run: | |
| 33 | + cd $GITHUB_WORKSPACE/2ms |
| 34 | + go build -o $GITHUB_WORKSPACE/2ms/dist/2ms main.go |
| 35 | + chmod +x $GITHUB_WORKSPACE/2ms/dist/2ms |
| 36 | +
|
| 37 | + - name: Checkout CLI repo |
| 38 | + uses: actions/checkout@v3 |
| 39 | + with: |
| 40 | + repository: ${{ vars.CES_EXECUTOR_REPO }} |
| 41 | + token: ${{ secrets.GITHUB }} |
| 42 | + path: cli |
| 43 | + ref: master |
| 44 | + |
| 45 | + - name: Build Engines Excutor |
| 46 | + run: | |
| 47 | + cd cli |
| 48 | + go build -o excutor |
| 49 | +
|
| 50 | + - name: Download projects from s3 |
| 51 | + run: | |
| 52 | + mkdir -p "$GITHUB_WORKSPACE/zips/" |
| 53 | + cd cli |
| 54 | + ./excutor sources -s $GITHUB_WORKSPACE/zips/ -e 2ms |
| 55 | + cd "$GITHUB_WORKSPACE/zips/" |
| 56 | + for zip in *.zip; do |
| 57 | + [ -e "$zip" ] || continue |
| 58 | + echo "::add-mask::$(pwd)/$zip" |
| 59 | + zip_name=$(basename "$zip" .zip) |
| 60 | + unzip -oq "$zip" -d "./$zip_name" |
| 61 | + done |
| 62 | + env: |
| 63 | + AWS_ACCESS_KEY_ID: ${{ secrets.CES_BUCKET_AWS_ACCESS_KEY }} |
| 64 | + AWS_SECRET_ACCESS_KEY: ${{ secrets.CES_BUCKET_AWS_SECRET_ACCESS_KEY }} |
| 65 | + AWS_REGION: ${{ secrets.CES_BUCKET_AWS_REGION }} |
| 66 | + |
| 67 | + - name: Create Metadata File |
| 68 | + run: | |
| 69 | + COMMIT_TIMESTAMP=$(git log -1 --format=%ct) |
| 70 | + METADATA_PATH="$GITHUB_WORKSPACE/pr-metadata.json" |
| 71 | + echo '{ |
| 72 | + "seq": "'"${COMMIT_TIMESTAMP}"'", |
| 73 | + "tag": "'"${{ github.event.number }}"'", |
| 74 | + "comment": "'"${{ github.event.pull_request.title }}"'", |
| 75 | + "commit": "'"${{ github.sha }}"'", |
| 76 | + "owner": "'"${{ github.actor }}"'", |
| 77 | + "branch": "'"${{ github.base_ref }}"'", |
| 78 | + "engine": "'"${ENGINE}"'", |
| 79 | + "platform": "'"${PLATFORM}"'", |
| 80 | + "version": "'"${ENGINE_VERSION}"'" |
| 81 | + }' > "$METADATA_PATH" |
| 82 | +
|
| 83 | + - name: Run Engines Executor |
| 84 | + run: | |
| 85 | + mkdir -p $GITHUB_WORKSPACE/results |
| 86 | + ./cli/excutor run -b $GITHUB_WORKSPACE/2ms/dist/2ms -s $GITHUB_WORKSPACE/zips/ -r $GITHUB_WORKSPACE/results -e $ENGINE -j $GITHUB_WORKSPACE/pr-metadata.json -p 1 --env $CES_ENVIROMENT |
| 87 | + env: |
| 88 | + AWS_ACCESS_KEY_ID: ${{ secrets.CES_BUCKET_AWS_ACCESS_KEY }} |
| 89 | + AWS_SECRET_ACCESS_KEY: ${{ secrets.CES_BUCKET_AWS_SECRET_ACCESS_KEY }} |
| 90 | + AWS_REGION: ${{ secrets.CES_BUCKET_AWS_REGION }} |
0 commit comments