2121 -name :Inject slug/short variables
2222uses :rlespinasse/github-slug-action@v3.x
2323
24- # - name: Print slug/short variables
25- # run: |
26- # echo "Slug variables"
27- # echo " ref : ${{ env.GITHUB_REF_SLUG }}"
28- # echo " head ref : ${{ env.GITHUB_HEAD_REF_SLUG }}"
29- # echo " base ref : ${{ env.GITHUB_BASE_REF_SLUG }}"
30- # echo " event ref : ${{ env.GITHUB_EVENT_REF_SLUG }}"
31- # echo " repository : ${{ env.GITHUB_REPOSITORY_SLUG }}"
32- # echo "Slug URL variables"
33- # echo " ref : ${{ env.GITHUB_REF_SLUG_URL }}"
34- # echo " head ref : ${{ env.GITHUB_HEAD_REF_SLUG_URL }}"
35- # echo " base ref : ${{ env.GITHUB_BASE_REF_SLUG_URL }}"
36- # echo " event ref : ${{ env.GITHUB_EVENT_REF_SLUG_URL }}"
37- # echo " repository : ${{ env.GITHUB_REPOSITORY_SLUG_URL }}"
38- # echo "Short SHA variables"
39- # echo " sha : ${{ env.GITHUB_SHA_SHORT }}"
40-
4124# https://github.com/actions/cache/blob/master/examples.md#java---gradle
4225 -name :save / load UI caches
4326id :ui-cache
@@ -81,31 +64,30 @@ jobs:
8164run :./gradlew build --no-daemon
8265
8366 -name :Docker Login
67+ if :github.repository == 'StubbornJava/StubbornJava'
8468run :echo ${{ secrets.SJ_OPS_GH_ACTION_CONTAINER_REGISTRY }} | docker login -u stubbornjava-ops --password-stdin https://containers.pkg.github.com
8569
8670 -name :Branch name
71+ if :github.repository == 'StubbornJava/StubbornJava'
8772run :echo running on branch ${{ env.GITHUB_REF_SLUG }}
8873
8974 -name :Build docker container for branch
75+ if :github.repository == 'StubbornJava/StubbornJava'
9076working-directory :./stubbornjava-webapp
9177run :docker build -t containers.pkg.github.com/stubbornjava/stubbornjava-webapp:${{ env.GITHUB_SHA_SHORT }} -f ./docker/Dockerfile .
9278
93- # See comment in file for the reason we are tagging this as prod.
94- # https://github.com/StubbornJava/StubbornJava/blob/master/k8s/stubbornjava.yaml
95- -name :Tag docker container for production
96- if :github.ref == 'refs/heads/master'
97- working-directory :./stubbornjava-webapp
98- run :docker tag containers.pkg.github.com/stubbornjava/stubbornjava-webapp:${{ env.GITHUB_SHA_SHORT }} containers.pkg.github.com/stubbornjava/stubbornjava-webapp:prod
99-
10079 -name :Push images and tags
80+ if :github.repository == 'StubbornJava/StubbornJava'
10181run :docker push containers.pkg.github.com/stubbornjava/stubbornjava-webapp
10282
10383# Deploy to k8s
104- deploy :
84+ deploy-prod :
10585needs :[build]
10686# Only auto deploy from master
107- if :github.ref == 'refs/heads/master'
87+ if :github.ref == 'refs/heads/master' && github.repository == 'StubbornJava/StubbornJava'
10888runs-on :ubuntu-latest
89+ env :
90+ KUBECONFIG :.kube/config
10991steps :
11092 -name :checkout
11193uses :actions/checkout@v2
@@ -114,6 +96,11 @@ jobs:
11496 -name :Inject slug/short variables
11597uses :rlespinasse/github-slug-action@v3.x
11698
99+ -name :Configure KUBECONFIG
100+ run :|
101+ mkdir -p .kube
102+ echo "${{ secrets.KUBE_CONFIG_DATA }}" | base64 -d > .kube/config
103+
117104 -name :Slack Notification - Deploying
118105uses :rtCamp/action-slack-notify@v2
119106env :
@@ -124,18 +111,10 @@ jobs:
124111SLACK_USERNAME :deploy_bot
125112SLACK_WEBHOOK :${{ secrets.SLACK_WEBHOOK }}
126113
127- -name :deploy to cluster
128- uses :steebchen/kubectl@v1.0.0
129- env :
130- KUBE_CONFIG_DATA :${{ secrets.KUBE_CONFIG_DATA }}
131- with :
132- args :set image --record deployment/stubbornjava-deployment sj-web=containers.pkg.github.com/stubbornjava/stubbornjava-webapp:${{ env.GITHUB_SHA_SHORT }}
133- -name :verify deployment
134- uses :steebchen/kubectl@v1.0.0
135- env :
136- KUBE_CONFIG_DATA :${{ secrets.KUBE_CONFIG_DATA }}
114+ -name :deploy stubbornjava
115+ uses :stefanprodan/kube-tools@v1
137116with :
138- args : ' "rollout status deployment/ stubbornjava-deployment" '
117+ command : helmv3 upgrade --install --wait stubbornjava k8s/chart/ --set image=containers.pkg.github.com/ stubbornjava/stubbornjava-webapp:${{ env.GITHUB_SHA_SHORT }}
139118
140119 -name :Slack Notification - Deploy Failed
141120if :${{ failure() }}