diff --git a/.github/workflows/trigger-jenkins.yml b/.github/workflows/trigger-jenkins.yml index 591cea25c..c1e82105f 100644 --- a/.github/workflows/trigger-jenkins.yml +++ b/.github/workflows/trigger-jenkins.yml @@ -1,15 +1,10 @@ -on: push +# on: push -jobs: - launch_jenkins_job: - name: trigger jenkins job - runs-on: ubuntu-latest - steps: - - - name: Trigger Jenkins Job - uses: sbitio/trigger-jenkins-job@jenkins - # with: - # JENKINS_USER: ${{ secrets.JENKINS_USER }} - # JENKINS_TOKEN: ${{ secrets.JENKINS_TOKEN }} - # JENKINS_HOST: ${{ secrets.JENKINS_HOST }} - # JENKINS_JOB: ${{ secrets.JENKINS_JOB }} \ No newline at end of file +# jobs: +# launch_jenkins_job: +# name: trigger jenkins job +# runs-on: ubuntu-latest +# steps: +# - +# name: Trigger Jenkins Job +# uses: sbitio/trigger-jenkins-job@master \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 000000000..84be4bc1b --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,111 @@ +def allowedBranches = ["main", "jenkins"] + +def uploadedFiles = "" + +pipeline { + agent { + kubernetes { + label 'dind-agent' + } + } + environment { + GIT_AUTHOR_NAME = "Jenkins" + GIT_COMMITTER_NAME = "Jenkins" + } + + stages { + + stage('Getting Commit Id of Last Push') { + steps { + script { + echo "bob started building" + + env.LAST_PUSH = """${sh( + returnStdout: true, + script: ''' + set +x; + cat s3LastCommitPush.txt + ''' + )}""" + + echo "last push commit Id ${env.LAST_PUSH}" + } + } + } + + stage('Uploading Asstes') { + steps { + script { + def changedFiles = """${sh( + returnStdout: true, + script: ''' + set +x; + git diff ${LAST_PUSH} ${GIT_COMMIT} --name-only --diff-filter=AMR; + ''' + )}""".trim().split("\n") + + for (file in changedFiles) { + def contentType = "" + if (file == 'package.json') { + continue; + } else if (file ==~ '.*\\.mp4$') { + contentType = "video/mp4" + } else if (file ==~ '.*\\.mp3$') { + contentType = "audio/mpeg" + } else if (file ==~ '.*\\.png$') { + contentType = "image/png" + } else if (file ==~ '.*\\.gif$') { + contentType = "image/gif" + } else if (file ==~ '.*\\.ttf$') { + contentType = "application/font-sfnt" + } else if (file ==~ '.*\\.json$') { + contentType = "application/json" + } else if (file ==~ '.*\\.svg$') { + contentType = "image/svg+xml" + } + else { + continue + } + + echo "bob is pushing file ${file} to s3" + + def s3Path = "s3://beckn-frontend-assets/${file}" + + sh "chmod +x ./push.sh" + sh ("./push.sh ${file} --no-compress --no-resize --no-check") + + uploadedFiles += "\n${file}" + } + } + } + } + + stage('Updating S3 Push Record') { + steps { + script { + env.SUMMARY = "Files Uploaded: ${uploadedFiles == '' ? 'NA' : uploadedFiles}" + + def branchName = 'jenkins' + def commitMessage = "[skip ci] updating s3LastCommitPush" + + sh "git config user.email 'namma.yatri.jenkins@gmail.com'" + sh "git config user.name 'ny-jenkins'" + + sh "git remote set-url origin git@github.com:nammayatri/asset-store.git" + sh "git checkout ${branchName}" + + sh "echo ${GIT_COMMIT} > s3LastCommitPush.txt" + sh "git add s3LastCommitPush.txt" + + sh "git commit -m \"${commitMessage}\"" + sh "git push" + + echo "${SUMMARY}" + + echo "bob builded successfully 😎" + } + } + } + + } +} diff --git a/beckn/passculture/user/images/ic_white_taxi.png b/beckn/passculture/user/images/dummy5.png similarity index 100% rename from beckn/passculture/user/images/ic_white_taxi.png rename to beckn/passculture/user/images/dummy5.png diff --git a/beckn/passculture/user/images/dummy6.png b/beckn/passculture/user/images/dummy6.png new file mode 100644 index 000000000..5d87f4db8 Binary files /dev/null and b/beckn/passculture/user/images/dummy6.png differ diff --git a/push.sh b/push.sh index 5c9454b92..a625d44a8 100644 --- a/push.sh +++ b/push.sh @@ -50,7 +50,8 @@ check_if_png_is_valid() invalidate_asset() { s3_path="$1" - npm run cdn:invalidate $s3_path --prefix node_modules/release-scripts + aws cloudfront create-invalidation --distribution-id $distributionId --paths $s3_path + printf "invalidated $s3_path" } push_asset() { @@ -64,18 +65,19 @@ push_asset() { printf "Pushing $local_path to $s3_path ...\n\n" - npm run s3:uploadFile $local_path $s3_path --prefix node_modules/release-scripts -- --public --titan # TODO :: create promise for api call to S3 + aws s3 cp $local_path $s3_path } asset="" -bucket=jp-remote-assets # TODO : set PROD bucket +bucket="beckn-frontend-assets" # TODO : PROD bucket +distributionId="EZCA94ADQWCV1" force_push=false if [ $(echo $@ | sed "s/--[a-zA-Z]*-*[a-zA-Z]*//g" | tr -d '[:space:]' | wc -c) -ne 0 ] then asset=$(echo $@ | sed "s/--[a-zA-Z]*-*[a-zA-Z]*//g" | tr -d '[:space:]'); fi if [[ "$@" =~ --sandbox ]] -then bucket="beta-hyper-sdk-assets"; fi # TODO :: set sandbox bucket (optional) +then bucket="beckn-frontend-assets"; fi # TODO :: sandbox bucket (optional) echo -------------- s3 push starting ------------------- @@ -123,5 +125,5 @@ then pathToPush="s3://$bucket/$asset" push_asset $local_path $pathToPush - invalidate_asset $pathToPush + # invalidate_asset $local_path fi \ No newline at end of file diff --git a/s3LastCommitPush.txt b/s3LastCommitPush.txt new file mode 100644 index 000000000..4bf21d9aa --- /dev/null +++ b/s3LastCommitPush.txt @@ -0,0 +1 @@ +3ea1db36fefc3187bd38972210107c95233dc885