Fix auth url for remote next. #104
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
name: Build and Deploy Docker Image to EC2 | |
on: | |
push: | |
branches: | |
- deploy-next | |
jobs: | |
build-next-image: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Login to Docker Hub | |
run: echo ${{ secrets.DOCKER_REGISTRY_TOKEN }} | docker login -u ${{ secrets.DOCKER_REGISTRY_USERNAME }} --password-stdin | |
- name: Build Docker image | |
run: docker build -t elarsaks/gorilla-labs-client:${{ github.sha }} ./apps/client | |
- name: Push Docker image to Docker Hub | |
run: docker push elarsaks/gorilla-labs-client:${{ github.sha }} | |
deploy-to-ec2: | |
needs: build-next-image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Docker Pull & Run From Hub | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.EC2_HOST }} | |
key: ${{ secrets.EC2_SSH_PRIVATE_KEY }} | |
username: ubuntu | |
script: | | |
echo ${{ secrets.DOCKER_REGISTRY_TOKEN }} | docker login -u ${{ secrets.DOCKER_REGISTRY_USERNAME }} --password-stdin | |
docker pull elarsaks/gorilla-labs-client:${{ github.sha }} | |
# Check if the container is running and stop it | |
if docker ps -q -f name=gorilla-labs-client; then | |
docker stop gorilla-labs-client | |
fi | |
# Check if the container exists and remove it | |
if docker ps -a -q -f name=gorilla-labs-client; then | |
docker rm gorilla-labs-client | |
fi | |
# Run the new gorilla-labs-client container with restart policy, connected to the network | |
docker run -d --restart=always \ | |
--name gorilla-labs-client \ | |
--network gorilla-labs-network \ | |
-p 3000:3000 \ | |
-e NEXTAUTH_URL=https://gorilla-labs.com/api/auth/callback/linkedin \ | |
-e NEXTAUTH_SECRET=${{ secrets.NEXTAUTH_SECRET }} \ | |
-e NEXT_LINKEDIN_CLIENT_ID=${{ secrets.NEXT_LINKEDIN_CLIENT_ID }} \ | |
-e NEXT_LINKEDIN_CLIENT_SECRET=${{ secrets.NEXT_LINKEDIN_CLIENT_SECRET }} \ | |
elarsaks/gorilla-labs-client:${{ github.sha }} | |
# Cleanup unused Docker images to free up space | |
docker image prune -af |