Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 30 additions & 49 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,57 +3,38 @@ on:
push:
branches: [main]
workflow_dispatch:
env:
DOMAIN_NAME: 'www.tokenpage.xyz'
DIST_DIR: './dist'
jobs:
deploy-app:
deploy:
runs-on: ubuntu-latest
env:
DOCKER_IMAGE: ghcr.io/${{ github.repository }}-app:latest
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Login to GitHub container registry
uses: docker/login-action@v2
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build docker image
uses: docker/build-push-action@v2
node-version: 20
cache: npm
- name: Install Dependencies
run: npm ci
- name: Build Site
run: npm run build
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
context: .
push: true
cache-from: type=gha,scope=app
cache-to: type=gha,mode=max,scope=app
tags: ${{ env.DOCKER_IMAGE }}
run-app:
needs: deploy-app
runs-on: ubuntu-latest
env:
NAME: tokenpage-landing-app
DOCKER_IMAGE: ghcr.io/${{ github.repository }}-app:latest
steps:
- name: executing remote ssh commands
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.MDTPBOX_URL }}
username: ${{ secrets.MDTPBOX_USER }}
key: ${{ secrets.MDTPBOX_SSH_KEY }}
port: ${{ secrets.MDTPBOX_PORT }}
envs: DOCKER_IMAGE,NAME
script_stop: true
script: |
url="www.tokenpage.xyz"
docker pull ${DOCKER_IMAGE}
docker stop ${NAME} && docker rm ${NAME} || true
docker run \
--name ${NAME} \
--detach \
--publish-all \
--restart unless-stopped \
--env NAME=${NAME} \
--env VIRTUAL_HOST=${url} \
--env LETSENCRYPT_HOST=${url} \
--env-file ~/.${NAME}.vars \
${DOCKER_IMAGE}
aws-access-key-id: ${{ secrets.SITE_DEPLOYER_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.SITE_DEPLOYER_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.SITE_DEPLOYER_AWS_REGION }}
Comment on lines +24 to +29
- name: Sync to S3
run: |
aws s3 sync \
--delete \
${{ env.DIST_DIR }} \
s3://${{ secrets.SITE_DEPLOYMENT_S3_BUCKET_NAME }}/${{ env.DOMAIN_NAME }}/
- name: Invalidate CloudFront Cache
run: |
aws cloudfront create-invalidation \
--distribution-id ${{ secrets.SITE_DEPLOYMENT_CLOUDFRONT_ID }} \
--paths "/${{ env.DOMAIN_NAME }}/*"
21 changes: 10 additions & 11 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@ on:
pull_request:
branches: [main]
jobs:
build-app:
build-site:
runs-on: ubuntu-latest
env:
DOCKER_IMAGE: build
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build docker image
uses: docker/build-push-action@v2
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
context: .
cache-from: type=gha,scope=app
cache-to: type=gha,mode=max,scope=app
node-version: 20
cache: npm
- name: Install dependencies
run: npm ci
- name: Build static site
run: npm run build
Loading