encode short urls, emojis 🥳 (#10) #30
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, Dockerize, Deploy Go App | |
on: | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- '**README.md' | |
- 'LICENSE' | |
- 'docs/**' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Set outputs | |
id: vars | |
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
- name: Install Dependencies | |
run: | | |
npm install -D tailwindcss | |
npx tailwindcss init | |
- name: Build Tailwind CSS | |
run: | | |
npm run build | |
- name: Setup Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.21' | |
- name: Build Go App | |
run: | | |
go build -ldflags='-s -w' -o=./api ./cmd/api | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
push: true | |
tags: bueti/shrinkster:${{ steps.vars.outputs.sha_short }} | |
deploy: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Set outputs | |
id: vars | |
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
- name: Generate ioverlander.env | |
uses: SpicyPizza/create-envfile@v2 | |
with: | |
envkey_SMTP_PASSWORD: ${{ secrets.SMTP_PASSWORD }} | |
envkey_SIGNING_KEY: ${{ secrets.SIGNING_KEY }} | |
envkey_TLS_CERT: ${{ secrets.TLS_CERT }} | |
envkey_TLS_KEY: ${{ secrets.TLS_KEY }} | |
envkey_DSN: ${{ secrets.DSN }} | |
envkey_SHA_SHORT: ${{ steps.vars.outputs.sha_short }} | |
envkey_AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
envkey_AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
directory: . | |
file_name: .env | |
- name: Copy Config to Server | |
uses: appleboy/scp-action@v0.1.4 | |
with: | |
host: ${{ secrets.SSH_HOST }} | |
username: ${{ secrets.SSH_USERNAME }} | |
key: ${{ secrets.SSH_KEY }} | |
source: ".env,compose.yaml" | |
target: "/home/ubuntu/shrinkster" | |
- name: Deploy to Server | |
uses: appleboy/ssh-action@v1.0.0 | |
with: | |
host: ${{ secrets.SSH_HOST }} | |
username: ${{ secrets.SSH_USERNAME }} | |
key: ${{ secrets.SSH_KEY }} | |
script: | | |
cd shrinkster | |
export TAG=$(grep SHA_SHORT .env | cut -d '=' -f2) | |
docker compose pull | |
docker compose up -d |