-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Slightly improved deployment syntax, and added example deployment
- Loading branch information
Showing
3 changed files
with
132 additions
and
4 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,128 @@ | ||
# After forking the repository | ||
# copy and adjust this deployment | ||
# file to setup an automated deployment | ||
# from the new, forked repository | ||
|
||
name: Example deployment | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
NCCRD_IMAGE_NAME: ${{ github.repository }}_example_node | ||
NGINX_IMAGE_NAME: ${{ github.repository }}_example_nginx | ||
BRANCH_REF: main | ||
DEPLOYMENT_HOSTNAME: ${{ secrets.DEPLOYMENT_HOSTNAME }} # Add as repository secret | ||
DEPLOYMENT_HOST_USERNAME: ${{ secrets.DEPLOYMENT_HOST_USERNAME }} # Add as repository secret | ||
DEPLOYMENT_HOST_PASSWORD: ${{ secrets.DEPLOYMENT_HOST_PASSWORD }} # Add as repository secret | ||
DEPLOYMENT_HOST_SSH_PORT: ${{ secrets.DEPLOYMENT_HOST_SSH_PORT }} # Add as repository secret | ||
ODP_AUTH_CLIENT_SECRET: ${{ secrets.ODP_AUTH_CLIENT_SECRET }} # Add as repository secret | ||
MSSQL_PASSWORD: ${{ secrets.MSSQL_PASSWORD }} # Add as repository secret | ||
MSSQL_USERNAME: ${{ secrets.MSSQL_USERNAME }} # Add as repository secret | ||
|
||
jobs: | ||
build-nginx: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
image: ${{ steps.meta.outputs.tags }} | ||
steps: | ||
- name: Checkout source code | ||
uses: actions/checkout@v2 | ||
with: | ||
ref: ${{ env.BRANCH_REF }} | ||
|
||
- name: Log in to the Container registry | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@v3 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.NGINX_IMAGE_NAME }} | ||
tags: | | ||
type=sha | ||
- name: Build and push NCCRD | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: src/nginx | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
|
||
build-nccrd: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
image: ${{ steps.meta.outputs.tags }} | ||
steps: | ||
- name: Check out source code (shared) | ||
uses: actions/checkout@v2 | ||
with: | ||
ref: ${{ env.BRANCH_REF }} | ||
|
||
- name: Log in to the Container registry | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@v3 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.NCCRD_IMAGE_NAME }} | ||
tags: | | ||
type=sha | ||
- name: Build and push NCCRD | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
build-args: | | ||
HOSTNAME=https://your-domain.com | ||
DEFAULT_NOTICES="This is the new deployment!,info" | ||
SHOW_DEV_WARNING="true" | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
|
||
deploy: | ||
needs: [build-nginx, build-nccrd] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout source code | ||
uses: actions/checkout@v2 | ||
with: | ||
ref: ${{ env.BRANCH_REF }} | ||
|
||
- name: (SCP) Copy Docker files to app server | ||
uses: appleboy/scp-action@master | ||
with: | ||
host: ${{ env.DEPLOYMENT_HOSTNAME }} | ||
username: ${{ env.DEPLOYMENT_HOST_USERNAME }} | ||
password: ${{ env.DEPLOYMENT_HOST_PASSWORD }} | ||
port: ${{ env.DEPLOYMENT_HOST_SSH_PORT }} | ||
source: 'deploy/stable/stack.yml' | ||
target: 'nccrd-stable' | ||
|
||
- name: (SSH) Deploy Docker stack | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ env.DEPLOYMENT_HOSTNAME }} | ||
username: ${{ env.DEPLOYMENT_HOST_USERNAME }} | ||
password: ${{ env.DEPLOYMENT_HOST_PASSWORD }} | ||
port: ${{ env.DEPLOYMENT_HOST_SSH_PORT }} | ||
script: | | ||
echo "MSSQL_PASSWORD=${{ env.MSSQL_PASSWORD }}" > /home/runner/nccrd-stable/deploy/stable/stack.env | ||
echo "MSSQL_USERNAME=${{ env.MSSQL_USERNAME }}" >> /home/runner/nccrd-stable/deploy/stable/stack.env | ||
echo "NCCRD_IMAGE=${{ needs.build-nccrd.outputs.image }}" >> /home/runner/nccrd-stable/deploy/stable/stack.env | ||
echo "NGINX_IMAGE=${{ needs.build-nginx.outputs.image }}" >> /home/runner/nccrd-stable/deploy/stable/stack.env | ||
echo "ODP_AUTH_CLIENT_SECRET=${{ env.ODP_AUTH_CLIENT_SECRET }}" >> /home/runner/nccrd-stable/deploy/stable/stack.env | ||
export $(cat /home/runner/nccrd-stable/deploy/stable/stack.env) > /dev/null 2>&1; | ||
docker stack deploy -c /home/runner/nccrd-stable/deploy/stable/stack.yml nccrd_stable |
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