-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update deploy.yml to use lowercase repo name * Update lint.yml do not include .github folder * Define reusable deploy workflow with variables to use for staging and beta * Add workflow config for beta * Use specific version of fifsky ssh action
- Loading branch information
Showing
4 changed files
with
87 additions
and
23 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 |
---|---|---|
@@ -1,45 +1,54 @@ | ||
name: deploy | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'development' | ||
pull_request: | ||
branches: | ||
- 'development' | ||
types: | ||
- 'closed' | ||
workflow_call: | ||
inputs: | ||
envname: | ||
required: true | ||
type: string | ||
docker_tag: | ||
required: true | ||
type: string | ||
docker_port: | ||
required: true | ||
type: number | ||
secrets: | ||
host: | ||
required: true | ||
user: | ||
required: true | ||
private_key: | ||
required: true | ||
|
||
jobs: | ||
deploy_staging: | ||
if: github.event_name == 'push' || github.event.pull_request.merged == true | ||
deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Docker Image Identifiers | ||
- name: Convert repository name to lower case | ||
run: | | ||
echo REPOSITORY_LC=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Build and push | ||
uses: docker/build-push-action@v2 | ||
with: | ||
push: true | ||
tags: ghcr.io/${{ env.REPOSITORY_LC }}:latest | ||
- name: Login to production server and deploy for staging | ||
uses: fifsky/ssh-action@master | ||
tags: ghcr.io/${{ env.REPOSITORY_LC }}:${{inputs.docker_tag}} | ||
- name: Login to production server and deploy | ||
uses: fifsky/ssh-action@v0.0.6 | ||
with: | ||
command: | | ||
docker stop $(docker ps -aq --filter "name=staging") | ||
docker rm $(docker ps -aq --filter "name=staging") | ||
docker image rm ghcr.io/${{ env.REPOSITORY_LC }}:latest | ||
docker stop $(docker ps -aq --filter "name=${{inputs.envname}}") | ||
docker rm $(docker ps -aq --filter "name=${{inputs.envname}}") | ||
docker image rm ghcr.io/${{ env.REPOSITORY_LC }}:${{inputs.docker_tag}} | ||
export CR_GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} | ||
echo $CR_GITHUB_TOKEN | docker login ghcr.io -u ${{ github.repository_owner }} --password-stdin | ||
docker pull ghcr.io/${{ env.REPOSITORY_LC }}:latest | ||
docker run --name staging -d -p 8000:80 --restart unless-stopped ghcr.io/${{ env.REPOSITORY_LC }}:latest | ||
host: ${{ secrets.HOST }} | ||
user: ${{ secrets.USER }} | ||
key: ${{ secrets.PRIVATE_KEY}} | ||
docker pull ghcr.io/${{ env.REPOSITORY_LC }}:${{inputs.docker_tag}} | ||
docker run --name ${{inputs.envname}} -d -p ${{inputs.docker_port}}:80 --restart unless-stopped ghcr.io/${{ env.REPOSITORY_LC }}:${{inputs.docker_tag}} | ||
host: ${{ secrets.host }} | ||
user: ${{ secrets.user }} | ||
key: ${{ secrets.private_key }} |
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,27 @@ | ||
name: deploy | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'master' | ||
pull_request: | ||
branches: | ||
- 'master' | ||
types: | ||
- 'closed' | ||
|
||
jobs: | ||
deploy_staging: | ||
if: github.event_name == 'push' || github.event.pull_request.merged == true | ||
uses: ./.github/workflows/deploy.yml | ||
with: | ||
envname: beta | ||
docker_tag: main | ||
docker_port: 8001 | ||
secrets: | ||
host: ${{secrets.HOST}} | ||
user: ${{secrets.USER}} | ||
private_key: ${{secrets.PRIVATE_KEY}} | ||
|
||
|
||
|
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,27 @@ | ||
name: deploy | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'development' | ||
pull_request: | ||
branches: | ||
- 'development' | ||
types: | ||
- 'closed' | ||
|
||
jobs: | ||
deploy_staging: | ||
if: github.event_name == 'push' || github.event.pull_request.merged == true | ||
uses: ./.github/workflows/deploy.yml | ||
with: | ||
envname: staging | ||
docker_tag: latest | ||
docker_port: 8000 | ||
secrets: | ||
host: ${{secrets.HOST}} | ||
user: ${{secrets.USER}} | ||
private_key: ${{secrets.PRIVATE_KEY}} | ||
|
||
|
||
|
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