-
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.
adding deployment to dockerhub, conventional vm, google container reg…
…istry and elastic container registry (aws)
- Loading branch information
unisbadri
committed
Apr 16, 2021
1 parent
fe77ed1
commit 218b35f
Showing
4 changed files
with
196 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: Deploy to Dockerhub | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'dockerhub-v*' | ||
|
||
jobs: | ||
Release: | ||
name: Release | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
# Getting tag name for docker image and full tag name. | ||
- name: Get tag version | ||
id: branch_name | ||
run: | | ||
echo ::set-output name=SOURCE_TAG_DOCKER_IMAGE::${GITHUB_REF#refs/tags/dockerhub-v} | ||
echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/} | ||
# Login to Docker | ||
- name: Login to DockerHub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
# Build and push docker image to Dockerhub | ||
- name: Build and push | ||
id: docker_build | ||
uses: docker/build-push-action@v2 | ||
with: | ||
push: true | ||
tags: namikazebadri/codeigniter-app:${{ steps.branch_name.outputs.SOURCE_TAG_DOCKER_IMAGE }} | ||
|
||
# Outputting image digest from push | ||
- name: Image digest | ||
run: echo ${{ steps.docker_build.outputs.digest }} | ||
|
||
# Notify engineers via slack | ||
- name: Notify slack | ||
uses: rtCamp/action-slack-notify@v2 | ||
env: | ||
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_OPEN_SOURCE }} | ||
SLACK_USERNAME: "Open Source Activities" | ||
SLACK_TITLE: "New Version Release!" | ||
SLACK_MESSAGE: "\n\n === ${{ github.repository }} (${{ steps.branch_name.outputs.SOURCE_TAG }}) ===" | ||
SLACK_FOOTER: "Powered by Element Creative Studio" | ||
SLACK_ICON: "https://cdn.elementcreativestudio.com/github.png" |
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,42 @@ | ||
name: Deploy to ECR | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'ecr-v*' | ||
|
||
jobs: | ||
Release: | ||
name: Release | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
# Getting tag name for docker image and full tag name. | ||
- name: Get tag version | ||
id: branch_name | ||
run: | | ||
echo ::set-output name=SOURCE_TAG_DOCKER_IMAGE::${GITHUB_REF#refs/tags/ecr-v} | ||
echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/} | ||
# Deploying image to Elastic Container Registry | ||
- run: docker build . --tag codeigniter-app:${{ steps.branch_name.outputs.SOURCE_TAG_DOCKER_IMAGE }} | ||
- name: Push to ECR | ||
id: ecr | ||
uses: jwalton/gh-ecr-push@v1 | ||
with: | ||
access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
region: ap-southeast-1 | ||
image: codeigniter-app:${{ steps.branch_name.outputs.SOURCE_TAG_DOCKER_IMAGE }} | ||
|
||
# Notify engineers via slack | ||
- name: Notify slack | ||
uses: rtCamp/action-slack-notify@v2 | ||
env: | ||
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_OPEN_SOURCE }} | ||
SLACK_USERNAME: "Open Source Activities" | ||
SLACK_TITLE: "New Version Release!" | ||
SLACK_MESSAGE: "\n\n === ${{ github.repository }} (${{ steps.branch_name.outputs.SOURCE_TAG }}) ===" | ||
SLACK_FOOTER: "Powered by Element Creative Studio" | ||
SLACK_ICON: "https://cdn.elementcreativestudio.com/github.png" |
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,42 @@ | ||
name: Deploy to GCR | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'gcr-v*' | ||
|
||
jobs: | ||
Release: | ||
name: Release | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
# Getting tag name for docker image and full tag name. | ||
- name: Get tag version | ||
id: branch_name | ||
run: | | ||
echo ::set-output name=SOURCE_TAG_DOCKER_IMAGE::${GITHUB_REF#refs/tags/gcr-v} | ||
echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/} | ||
# Deploying image to Google Container Registry | ||
- name: Deploying docker image to GCR | ||
uses: RaccoonDev/push-docker-gcr@v1 | ||
with: | ||
gcr_host: gcr.io | ||
image_name: codeigniter-app | ||
image_tag: ${{ steps.branch_name.outputs.SOURCE_TAG_DOCKER_IMAGE }} | ||
env: | ||
GCLOUD_SERVICE_KEY: ${{ secrets.GCLOUD_SERVICE_KEY }} | ||
GOOGLE_PROJECT_ID: ${{ secrets.GOOGLE_PROJECT_ID }} | ||
|
||
# Notify engineers via slack | ||
- name: Notify slack | ||
uses: rtCamp/action-slack-notify@v2 | ||
env: | ||
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_OPEN_SOURCE }} | ||
SLACK_USERNAME: "Open Source Activities" | ||
SLACK_TITLE: "New Version Release!" | ||
SLACK_MESSAGE: "\n\n === ${{ github.repository }} (${{ steps.branch_name.outputs.SOURCE_TAG }}) ===" | ||
SLACK_FOOTER: "Powered by Element Creative Studio" | ||
SLACK_ICON: "https://cdn.elementcreativestudio.com/github.png" |
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,62 @@ | ||
name: Deploy to VM Instance(s) | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'vm-v*' | ||
|
||
jobs: | ||
Release: | ||
name: Release | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
# Getting tag name for docker image and full tag name. | ||
- name: Get tag version | ||
id: branch_name | ||
run: | | ||
echo ::set-output name=SOURCE_TAG_DOCKER_IMAGE::${GITHUB_REF#refs/tags/vm-v} | ||
echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/} | ||
# Login to Docker | ||
- name: Login to DockerHub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
# Build and push docker image to Dockerhub | ||
- name: Build and push | ||
id: docker_build | ||
uses: docker/build-push-action@v2 | ||
with: | ||
push: true | ||
tags: namikazebadri/codeigniter-app:${{ steps.branch_name.outputs.SOURCE_TAG_DOCKER_IMAGE }} | ||
|
||
# Outputting image digest from push | ||
- name: Image digest | ||
run: echo ${{ steps.docker_build.outputs.digest }} | ||
|
||
# Deploying image to VM Machine using docker | ||
- name: Deploying docker image to VM Machine | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.SSH_HOST }} | ||
username: ubuntu | ||
key: ${{ secrets.SSH_PRIVATE_KEY }} | ||
port: 22 | ||
script: | | ||
whoami | ||
docker run -d -p 80:80 --name codeigniter-app namikazebadri/codeigniter-app:${{ steps.branch_name.outputs.SOURCE_TAG_DOCKER_IMAGE }} | ||
# Notify engineers via slack | ||
- name: Notify slack | ||
uses: rtCamp/action-slack-notify@v2 | ||
env: | ||
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_OPEN_SOURCE }} | ||
SLACK_USERNAME: "Open Source Activities" | ||
SLACK_TITLE: "New Version Release!" | ||
SLACK_MESSAGE: "\n\n === ${{ github.repository }} (${{ steps.branch_name.outputs.SOURCE_TAG }}) ===" | ||
SLACK_FOOTER: "Powered by Element Creative Studio" | ||
SLACK_ICON: "https://cdn.elementcreativestudio.com/github.png" |