Adding gitea workflow
This commit is contained in:
parent
e8c75b1276
commit
c2aee1633b
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@ -48,6 +48,9 @@
|
||||
// File Icons
|
||||
// ============================
|
||||
"workbench.iconTheme": "material-icon-theme",
|
||||
"material-icon-theme.folders.associations": {
|
||||
"gitea/workflows": "repository",
|
||||
},
|
||||
|
||||
// ============================
|
||||
// Explorer cleanup
|
||||
|
||||
66
gitea/workflows/deploy.yml
Normal file
66
gitea/workflows/deploy.yml
Normal file
@ -0,0 +1,66 @@
|
||||
name: Build & Deploy Costco Grocery List
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "main" ]
|
||||
|
||||
env:
|
||||
IMAGE_NAME: costco-grocery-list
|
||||
REGISTRY: gitea.nicosaya.com
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
- name: Install backend dependencies
|
||||
working-directory: backend
|
||||
run: npm ci
|
||||
|
||||
- name: Run tests (if any)
|
||||
working-directory: backend
|
||||
run: npm test --if-present
|
||||
|
||||
- name: Docker login
|
||||
run: |
|
||||
echo "${{ secrets.REGISTRY_PASS }}" | docker login $REGISTRY \
|
||||
-u "${{ secrets.REGISTRY_USER }}" --password-stdin
|
||||
|
||||
- name: Build Docker image
|
||||
run: |
|
||||
docker build -t $REGISTRY/${{ env.IMAGE_NAME }}:${{ github.sha }} .
|
||||
docker tag $REGISTRY/${{ env.IMAGE_NAME }}:${{ github.sha }} $REGISTRY/${{ env.IMAGE_NAME }}:latest
|
||||
|
||||
- name: Push Docker image
|
||||
run: |
|
||||
docker push $REGISTRY/${{ env.IMAGE_NAME }}:${{ github.sha }}
|
||||
docker push $REGISTRY/${{ env.IMAGE_NAME }}:latest
|
||||
|
||||
deploy:
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Install SSH key
|
||||
run: |
|
||||
mkdir -p ~/.ssh
|
||||
echo "${{ secrets.DEPLOY_KEY }}" > ~/.ssh/id_ed25519
|
||||
chmod 600 ~/.ssh/id_ed25519
|
||||
ssh-keyscan -H "${{ secrets.DEPLOY_HOST }}" >> ~/.ssh/known_hosts
|
||||
|
||||
- name: Deploy via SSH
|
||||
run: |
|
||||
ssh ${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_HOST }} << 'EOF'
|
||||
cd /opt/costco-app
|
||||
docker compose pull
|
||||
docker compose up -d --remove-orphans
|
||||
docker image prune -f
|
||||
EOF
|
||||
Loading…
Reference in New Issue
Block a user