1- # Default to the read only token - the read/write token will be present on Travis CI .
2- # It's set as a secure environment variable in the .travis .yml file
1+ # Default to the read only token - the read/write token will be present on GitHub Action .
2+ # It's set as a secure environment variable in the build .yml file
33PACTICIPANT := "pactflow-example-consumer-python"
44GITHUB_WEBHOOK_UUID := "04510dc1-7f0a-4ed2-997d-114bfa86f8ad"
55PACT_CLI ="docker run --rm -v ${PWD}:${PWD} -e PACT_BROKER_BASE_URL -e PACT_BROKER_TOKEN -e PACT_BROKER_USERNAME -e PACT_BROKER_PASSWORD pactfoundation/pact-cli:latest"
66
77# Only deploy from master
8- ifeq ($(TRAVIS_BRANCH ) ,master)
8+ ifeq ($(GIT_BRANCH ) ,master)
99 DEPLOY_TARGET=deploy
1010else
1111 DEPLOY_TARGET=no_deploy
@@ -20,17 +20,17 @@ all: test
2020ci : test publish_pacts can_i_deploy $(DEPLOY_TARGET )
2121
2222# Run the ci target from a developer machine with the environment variables
23- # set as if it was on Travis CI .
23+ # set as if it was on GitHub Action .
2424# Use this for quick feedback when playing around with your workflows.
2525fake_ci : .env
2626 CI=true \
27- TRAVIS_COMMIT =` git rev-parse --short HEAD` +` date +%s` \
28- TRAVIS_BRANCH =` git rev-parse --abbrev-ref HEAD` \
27+ GIT_COMMIT =` git rev-parse --short HEAD` +` date +%s` \
28+ GIT_BRANCH =` git rev-parse --abbrev-ref HEAD` \
2929 REACT_APP_API_BASE_URL=http://localhost:8080 \
3030 make ci
3131
3232publish_pacts : .env
33- @" ${PACT_CLI} " publish ${PWD} /pacts --consumer-app-version ${TRAVIS_COMMIT } --tag ${TRAVIS_BRANCH }
33+ @" ${PACT_CLI} " publish ${PWD} /pacts --consumer-app-version ${GIT_COMMIT } --tag ${GIT_BRANCH }
3434
3535# # =====================
3636# # Build/test tasks
@@ -43,24 +43,39 @@ test: .env
4343# # Deploy tasks
4444# # =====================
4545
46- deploy : deploy_app tag_as_prod
46+ test : .env
47+ ./gradlew clean test -i
48+
49+ # # =====================
50+ # # Deploy tasks
51+ # # =====================
52+
53+ deploy : deploy_app tag record_deployment
4754
4855no_deploy :
4956 @echo " Not deploying as not on master branch"
5057
5158can_i_deploy : .env
59+ echo " can_i_deploy"
5260 @" ${PACT_CLI} " broker can-i-deploy \
5361 --pacticipant ${PACTICIPANT} \
54- --version ${TRAVIS_COMMIT } \
55- --to prod \
62+ --version ${GIT_COMMIT } \
63+ --to-environment production \
5664 --retry-while-unknown 0 \
5765 --retry-interval 10
5866
5967deploy_app :
6068 @echo " Deploying to prod"
6169
62- tag_as_prod : .env
63- @" ${PACT_CLI} " broker create-version-tag --pacticipant ${PACTICIPANT} --version ${TRAVIS_COMMIT} --tag prod
70+ tag : .env
71+ @" ${PACT_CLI} " broker create-version-tag \
72+ --pacticipant ${PACTICIPANT} \
73+ --version ${GIT_COMMIT} \
74+ --auto-create-version \
75+ --tag ${GIT_BRANCH}
76+
77+ record_deployment : .env
78+ @" ${PACT_CLI} " broker record-deployment --pacticipant ${PACTICIPANT} --version ${GIT_COMMIT} --environment production
6479
6580# # =====================
6681# # Pactflow set up tasks
@@ -94,17 +109,6 @@ create_or_update_github_webhook:
94109test_github_webhook :
95110 @curl -v -X POST ${PACT_BROKER_BASE_URL} /webhooks/${GITHUB_WEBHOOK_UUID} /execute -H " Authorization: Bearer ${PACT_BROKER_TOKEN} "
96111
97- # # ======================
98- # # Travis CI set up tasks
99- # # ======================
100-
101- travis_login :
102- @docker run --rm -v ${HOME} /.travis:/root/.travis -it lirantal/travis-cli login --pro
103-
104- # Requires PACT_BROKER_TOKEN to be set
105- travis_encrypt_pact_broker_token :
106- @docker run --rm -v ${HOME} /.travis:/root/.travis -v ${PWD} :${PWD} --workdir ${PWD} lirantal/travis-cli encrypt --pro PACT_BROKER_TOKEN=" ${PACT_BROKER_TOKEN} "
107-
108112# # ======================
109113# # Misc
110114# # ======================
0 commit comments