-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Create manual-dev-build.yaml * Update manual-dev-build.yaml * Update manual-dev-build.yaml * Update manual-dev-build.yaml * Added workflow dispatch * Updated action dispatch * Added ref * Set workflow name * Add deploy step * Run build on pr * Merge into dev * Added test workflow * Removed needs * Update user secret * Updated workflows to use dev * Updated workflows to use dev * Update manaul workflow
- Loading branch information
Showing
4 changed files
with
109 additions
and
51 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,51 @@ | ||
name: Build, push, deploy | ||
|
||
on: | ||
push: | ||
branches: [dev, main] | ||
|
||
env: | ||
IMAGE_NAME: api | ||
IMAGE_OWNER: bristolsta | ||
|
||
SERVICE_NAME: "${{ github.ref == 'refs/heads/main' && 'uobtheatre-api' || 'uobtheatre-api-staging' }}" | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
packages: write | ||
contents: read | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Build image | ||
run: docker build . --file compose/production/django/Dockerfile --tag ghcr.io/$IMAGE_OWNER/$IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}" | ||
|
||
- name: Log into registry | ||
# This is where you will update the PAT to GITHUB_TOKEN | ||
run: echo "${{ secrets.BRISTOLSTA_REGISTRY_PAT }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | ||
|
||
- name: Push image | ||
run: docker push ghcr.io/$IMAGE_OWNER/$IMAGE_NAME:latest | ||
|
||
deploy: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
- name: Deploy new image | ||
uses: appleboy/ssh-action@master | ||
env: | ||
SERVICE_NAME: $SERVICE_NAME | ||
with: | ||
host: ${{ secrets.SERVER_SSH_HOST }} | ||
username: ${{ secrets.SERVER_SSH_USER }} | ||
key: ${{ secrets.SERVER_SSH_KEY }} | ||
port: ${{ secrets.SERVER_SSH_PORT }} | ||
envs: SERVICE_NAME | ||
script: | | ||
cd /var/sta | ||
docker-compose pull $SERVICE_NAME | ||
docker-compose up -d $SERVICE_NAME | ||
docker-compose exec $SERVICE_NAME python manage.py migrate |
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,32 @@ | ||
name: Dev image build and push | ||
|
||
on: | ||
push: | ||
branches: | ||
- dev | ||
|
||
workflow_dispatch: | ||
|
||
env: | ||
DEV_IMAGE_NAME: api-dev | ||
IMAGE_OWNER: bristolsta | ||
|
||
jobs: | ||
build-dev: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
packages: write | ||
contents: read | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Build image | ||
run: docker build . --file compose/local/django/Dockerfile --tag ghcr.io/$IMAGE_OWNER/$DEV_IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}" | ||
|
||
- name: Log into registry | ||
# This is where you will update the PAT to GITHUB_TOKEN | ||
run: echo "${{ secrets.BRISTOLSTA_REGISTRY_PAT }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | ||
|
||
- name: Push image | ||
run: docker push ghcr.io/$IMAGE_OWNER/$DEV_IMAGE_NAME:latest |
This file was deleted.
Oops, something went wrong.
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,26 @@ | ||
name: Trigger dev build | ||
|
||
on: | ||
pull_request: | ||
types: [opened] | ||
issue_comment: | ||
types: [created] | ||
|
||
jobs: | ||
trigger-deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: khan/pull-request-comment-trigger@master | ||
id: check | ||
with: | ||
trigger: '!build-dev' | ||
reaction: rocket | ||
env: | ||
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' | ||
- name: Invoke workflow without inputs | ||
uses: benc-uk/workflow-dispatch@v1 | ||
if: steps.check.outputs.triggered == 'true' | ||
with: | ||
workflow: Dev image build and push | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
ref: ${{ github.event.pull_request.head.ref }} |