Skip to content

Merge branch 'development' of https://github.com/cmu-delphi/signal_do… #297

Merge branch 'development' of https://github.com/cmu-delphi/signal_do…

Merge branch 'development' of https://github.com/cmu-delphi/signal_do… #297

name: 'Build and deploy application containers'
on:
push:
jobs:
build-tag-push-deploy:
runs-on: ubuntu-latest
# CI/CD will run on these branches
if: >
github.ref == 'refs/heads/master' ||
github.ref == 'refs/heads/development'
strategy:
matrix:
# Specify the docker-compose services to build images from
service: [sdwebapp, sdnginx]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Login to GitHub container registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: cmu-delphi-deploy-machine
password: ${{ secrets.CMU_DELPHI_DEPLOY_MACHINE_PAT }}
- name: Create container image tags
id: image-tag
run: |
baseRef="${GITHUB_REF#*/}"
baseRef="${baseRef#*/}"
case "${baseRef}" in
master)
image_tag="latest"
;;
*)
image_tag="${baseRef//\//_}" # replace `/` with `_` in branch name
;;
esac
echo "IMAGE_TAG=${image_tag}" >> $GITHUB_OUTPUT
- name: Copy env file
run: |
cp ./.ci.env ./.env
- name: Set up docker-compose
uses: ndeloof/install-compose-action@v0.0.1
- name: docker-compose build --push
run: |
docker-compose build --push ${{ matrix.service }}
env:
TAG: ":${{ steps.image-tag.outputs.IMAGE_TAG }}"
REGISTRY: "ghcr.io/${{ github.repository_owner }}/"
- name: docker-compose down
run: |
docker-compose down
- name: Trigger smee.io webhook to pull new container images
run: |
curl -H "Authorization: Bearer ${{ secrets.DELPHI_DEPLOY_WEBHOOK_TOKEN }}" \
-X POST ${{ secrets.DELPHI_DEPLOY_WEBHOOK_URL }} \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "repository=ghcr.io/${{ github.repository }}-${{ matrix.service }}&tag=${{ steps.image-tag.outputs.IMAGE_TAG }}"