-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
88 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
{[define "DEPLOYMENT"]} | ||
- name: Fetch kubeconfig | ||
run: |- | ||
eval "$( aws sts assume-role --role-arn arn:aws:iam::{[.AWSAccountNumber]}:role/rolen-name-{[.Env]} --role-session session | jq -r '.Credentials | keys[] as $k | "\($k) \(.[$k])"' | awk '{ gsub(/[A-Z]/,"_&",$1); print "export","AWS"toupper($1)"="$2}' )" | ||
aws eks update-kubeconfig --name wave-eks-main-{[.Env]} --kubeconfig ./kubeconfig --region=eu-west-2 --role-arn arn:aws:iam::{[.AWSAccountNumber]}:role/role-name-{[.Env]} | ||
- name: Deploy to {[.Env]} | ||
run: | | ||
CHART_VERSION=$(cat CHART-VERSION) | ||
helm init --client-only | ||
helm repo add test $HELM_REPO_URL --username $ARTIFACTORY_USERNAME --password $ARTIFACTORY_PASSWORD && helm repo update | ||
echo "Running helm upgrade --install {[.Env]}-{[.Name]} --timeout 300 --version $CHART_VERSION --wait --set environment={[.Env]} --namespace={[.Env]} test/{[.Name]} --debug" | ||
if ! helm upgrade --install {[.Env]}-{[.Name]} --timeout 300 --version $CHART_VERSION --wait --set environment={[.Env]} --namespace={[.Env]} test/{[.Name]} --debug; then | ||
echo "Detected that the upgrade failed, attempting rollback." | ||
helm rollback {[.Env]}-{[.Name]} 0 | ||
curl -X POST \ | ||
https://hooks.slack.com/services/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 \ | ||
-H 'Content-Type: application/json' \ | ||
-d '{"channel": "#{[.Env]}-alerts","attachments": [ {"title": "Deployment failed to {[.Env]}","text": "{[.Name]} ('"$VERSION"') has NOT been deployed to {[.Env]}. Helm rolled back deployment.","color": "danger"} ] }' | ||
exit 1 | ||
fi | ||
- name: Tag HEAD with {[.Env]} | ||
run: |- | ||
echo "Tagging HEAD with {[.Env]}" | ||
if ! git tag -d {[.Env]} ; then | ||
echo "No tag to remove from git" | ||
fi | ||
git tag {[.Env]} | ||
git push --force origin refs/tags/{[.Env]}:refs/tags/{[.Env]} | ||
echo "Tagging complete" | ||
- name: publish to API Gateway {[.Env]} | ||
run: |- | ||
SERVICE_NAME={[.Name]} \ | ||
ASSUME_ROLE=arn:aws:iam::{[.AWSAccountNumber]}:role/githubaction-swagger-publisher-role-{[.Env]} \ | ||
ENVIRONMENT={[.Env]} \ | ||
CONNECTION_TYPE=VPC \ | ||
VPC_ID=${[.Env]}_VPC_ID \ | ||
API_GATEWAY_ID=${[.Env]}_API_GATEWAY_ID \ | ||
/bin/swagger-publisher; | ||
{[end]} | ||
|
||
name: Java CI with Maven | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up JDK 1.11 | ||
uses: actions/setup-java@v1 | ||
with: | ||
java-version: 1.11 | ||
- name: Build with Maven | ||
run: mvn -B package --file pom.xml -DskipTests -s .github/settings.xml | ||
|
||
- name: Run tests | ||
run: mvn -B package --file pom.xml | ||
- name: {[.service_name]} | ||
- name: Build | ||
run: |- | ||
docker build \ | ||
--tag "docker.pkg.github.com/$PROJECT_ID/$IMAGE:$GITHUB_SHA" \ | ||
--build-arg GITHUB_SHA="$GITHUB_SHA" \ | ||
--build-arg GITHUB_REF="$GITHUB_REF" \ | ||
. | ||
# Push the Docker image to Github registry | ||
- name: Publish | ||
run: |- | ||
docker push "docker.pkg.github.com/$PROJECT_ID/$IMAGE:$GITHUB_SHA" | ||
{[template "DEPLOYMENT" map "Env" "dev" "Name" .service_name "AWSAccountNumber" "326458601802" "key1" "value1" ]} | ||
{[template "DEPLOYMENT" map "Env" "staging" "Name" .service_name "AWSAccountNumber" "125695174157" "key1" "value1" ]} | ||
{[template "DEPLOYMENT" map "Env" "prod" "Name" .service_name "AWSAccountNumber" "430419974501" "key1" "value1" ]} | ||
|
||
|
||
|
||
|
||
|