Skip to content

Commit

Permalink
Merge pull request #3 from irazzhivin/master
Browse files Browse the repository at this point in the history
GitLab workflow and branch promote usage example
  • Loading branch information
irazzhivin authored Dec 20, 2022
2 parents 4a18c26 + e21e6f9 commit 06b91fc
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,42 @@ settings:
ghcr.io/fivexl/magic-button:${{ env.MAGIC_BUTTON_VERSION }}
&& ls -all magic-button/reports && cat magic-button/reports/report.json
continue-on-error: true
```
```

# GitLab Workflow + Branch promote Example
```
.magicbutton:
stage: .post
image:
name: docker:latest
services:
- docker:dind
allow_failure: true
before_script:
- apk update
- apk add git
script:
- |
mkdir -p magic-button/reports && chmod 777 magic-button/reports && docker run --rm -v "$(pwd)/.git":/app/.git -v "$(pwd)/magic-button/reports":/app/reports -e SLACK_BOT_TOKEN -e SLACK_APP_TOKEN -e BUILD_JOB_NAME -e BUILD_JOB_URL -e CURRENT_GIT_COMMIT="$(git rev-parse HEAD)" -e REPOSITORY_NAME="$(basename $(git rev-parse --show-toplevel))" -e REPOSITORY_URL -e BRANCHES_TO_PROMOTE -e TIMEOUT_MINUTES -e TIMEZONE="Europe/Oslo" -e PRODUCTION_BRANCHES -e SLACK_CHANNEL_NAME ghcr.io/fivexl/magic-button:$MAGIC_BUTTON_VERSION && ls -all magic-button/reports && cat magic-button/reports/report.json
after_script:
- >
if [ $CI_JOB_STATUS == 'success' ]; then
#Provide git credentials (e.g.: https://docs.gitlab.com/ee/ci/jobs/ci_job_token.html)
git remote set-url --push origin git@gitlab:$CI_PROJECT_PATH
git switch $BRANCHES_TO_PROMOTE
git push -f ssh_origin HEAD:$PRODUCTION_BRANCHES
else
echo 'Confirmation failed or is cancelled'
fi
promote:
stage: .post
extends: .magicbutton
rules:
- if: $CI_COMMIT_REF_NAME == $BRANCHES_TO_PROMOTE
```

0 comments on commit 06b91fc

Please sign in to comment.