-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #212 from camphor-/githubaction-prod
Prod環境、GitHub Actionでbuild と deploy
- Loading branch information
Showing
2 changed files
with
68 additions
and
18 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 |
---|---|---|
|
@@ -6,22 +6,78 @@ on: | |
- v[0-9]+.[0-9]+.[0-9]+ | ||
paths-ignore: | ||
- 'docs/**' | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Publish Docker | ||
uses: elgohr/[email protected] | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- name: Login to Docker Registry | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: registry.camph.net | ||
username: ${{ secrets.DOCKER_REGISTRY_USERNAME }} | ||
password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }} | ||
- name: Check out | ||
uses: actions/checkout@v2 | ||
- name: Build and push | ||
uses: docker/build-push-action@v2 | ||
with: | ||
push: true | ||
tags: registry.camph.net/relaym-server-prod:latest | ||
context: . | ||
file: ./docker/Dockerfile | ||
- name: Notify to Slack | ||
uses: craftech-io/slack-action@v1 | ||
with: | ||
slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }} | ||
if: failure() | ||
deploy: | ||
name: deploy | ||
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
- name: Install SSH key | ||
uses: shimataro/ssh-key-action@v2 | ||
with: | ||
key: ${{ secrets.KONOE_SSH_KEY }} | ||
name: id_rsa | ||
known_hosts: ${{ secrets.KONOE_KNOWN_HOSTS }} | ||
- name: Setup docker context | ||
run: | | ||
docker context create --default-stack-orchestrator=swarm --docker "host=ssh://${{ secrets.KONOE_SSH_USERNAME }}@${{ secrets.KONOE_SSH_HOST }}:${{ secrets.KONOE_SSH_PORT }}" konoe | ||
docker context use konoe | ||
- name: Login to Docker Registry | ||
uses: docker/login-action@v1 | ||
with: | ||
name: relaym-server-prod | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
registry: registry.camph.net | ||
dockerfile: docker/Dockerfile | ||
tags: "latest" | ||
- name: Notify to Rundeck | ||
uses: wei/[email protected] | ||
username: ${{ secrets.DOCKER_REGISTRY_USERNAME }} | ||
password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }} | ||
- name: Check out | ||
uses: actions/checkout@v2 | ||
- name: deploy relaym-server-prod | ||
run: | | ||
docker pull registry.camph.net/relaym-server-prod:latest | ||
docker-compose --context konoe -f docker/docker-compose.deps.base.yml -f docker/docker-compose.deps.prod.yml -p prod up -d | ||
docker-compose --context konoe -f docker/docker-compose.base.yml -f docker/docker-compose.prod.yml -p prod stop | ||
docker-compose --context konoe -f docker/docker-compose.base.yml -f docker/docker-compose.prod.yml -p prod up -d | ||
env: | ||
ENV: ${{ secrets.PROD_ENV }} | ||
DB_DATABASE: ${{ secrets.PROD_DB_DATABASE }} | ||
DB_USER: ${{ secrets.PROD_DB_USER }} | ||
DB_PASSWORD: ${{ secrets.PROD_DB_PASSWORD }} | ||
DB_ROOT_PASSWORD: ${{ secrets.PROD_DB_ROOT_PASSWORD }} | ||
DB_HOST: ${{ secrets.PROD_DB_HOST }} | ||
DB_PORT: ${{ secrets.PROD_DB_PORT }} | ||
SPOTIFY_REDIRECT_URL: ${{ secrets.PROD_SPOTIFY_REDIRECT_URL }} | ||
PORT: ${{ secrets.PROD_PORT }} | ||
SPOTIFY_CLIENT_ID: ${{ secrets.PROD_SPOTIFY_CLIENT_ID }} | ||
SPOTIFY_CLIENT_SECRET: ${{ secrets.PROD_SPOTIFY_CLIENT_SECRET }} | ||
CORS_ALLOW_ORIGIN: ${{ secrets.PROD_CORS_ALLOW_ORIGIN }} | ||
FRONTEND_URL: ${{ secrets.PROD_FRONTEND_URL }} | ||
- name: Notify to Slack | ||
uses: craftech-io/slack-action@v1 | ||
with: | ||
args: https://${{ secrets.RUNDECK_DOMAIN }}/api/1/job/${{ secrets.RUNDECK_JOB_ID_PROD }}/run?authtoken=${{ secrets.RUNDECK_TOKEN }} -X POST | ||
slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }} | ||
if: always() |
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