✨ npm update --save #18
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: Deployment | |
env: | |
CONTEXT_DIR: "./" | |
IMAGE_NAME: ${{ github.repository }} | |
DOCKERFILE: Dockerfile.caprover | |
CAPROVER_APP: resume | |
DOCKER_REGISTRY: ghcr.io | |
GOOGLE_TAG_ID: ${{secrets.GOOGLE_TAG_ID}} | |
POSTHOG_ID: ${{secrets.POSTHOG_ID}} | |
TELEGRAM_TO: ${{secrets.TELEGRAM_TO}} | |
TELEGRAM_TOKEN: ${{secrets.TELEGRAM_TOKEN}} | |
POSTHOG_WEBHOOK_TOKEN: ${{secrets.POSTHOG_WEBHOOK_TOKEN}} | |
on: | |
workflow_dispatch: | |
push: | |
branches: [main] | |
jobs: | |
build-and-publish: | |
name: Build and Push | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v1 | |
# Setup Docker Buildx | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
# Build and push Docker Image | |
- name: Login to Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Preset Image Name | |
run: echo "IMAGE_URL=$(echo ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:$(echo ${{ github.sha }} | cut -c1-7) | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV | |
- name: Build and push Docker Image | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: ./Dockerfile | |
push: true | |
tags: ${{ env.IMAGE_URL }} | |
build-args: | | |
GOOGLE_TAG_ID=${{ secrets.GOOGLE_TAG_ID }} | |
POSTHOG_ID=${{ secrets.POSTHOG_ID }} | |
TELEGRAM_TO=${{ secrets.TELEGRAM_TO }} | |
TELEGRAM_TOKEN=${{ secrets.TELEGRAM_TOKEN }} | |
POSTHOG_WEBHOOK_TOKEN=${{ secrets.POSTHOG_WEBHOOK_TOKEN }} | |
# Deploy to CapRover | |
- name: Deploy Image to CapRover | |
uses: caprover/deploy-from-github@v1.1.2 | |
with: | |
server: "${{ vars.CAPROVER_HOST }}" | |
app: "${{ vars.APP_NAME }}" | |
token: "${{ secrets.CAPROVER_APP_TOKEN }}" | |
image: ${{ env.IMAGE_URL }} | |
notify: | |
name: Notify | |
needs: [build-and-publish] | |
if: always() | |
runs-on: ubuntu-latest | |
steps: | |
- name: send telegram message on push | |
uses: appleboy/telegram-action@master | |
with: | |
to: ${{ secrets.TELEGRAM_TO }} | |
token: ${{ secrets.TELEGRAM_TOKEN }} | |
message: | | |
Deployment Status: ${{ job.status }} | |
${{ github.actor }}: | |
Commit message: ${{ github.event.commits[0].message }} | |
Repository: ${{ github.repository }} | |
See changes: https://github.com/${{ github.repository }}/commit/${{github.sha}} |