ci: add Gitea Actions workflow for build & deploy
Build & Deploy Mobile / build-and-deploy (push) Waiting to run
Build & Deploy Mobile / build-and-deploy (push) Waiting to run
Adds CI/CD pipeline that: - Builds Docker image on push to staging branch - Pushes to GHCR - Deploys to Swarm service
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
name: Build & Deploy Mobile
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- staging
|
||||
|
||||
env:
|
||||
REGISTRY: ghcr.io
|
||||
IMAGE_NAME: maifors/falah-mobile
|
||||
SWARM_SERVICE: falah_falah-mobile
|
||||
|
||||
jobs:
|
||||
build-and-deploy:
|
||||
runs-on: contabo
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Log in to Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ secrets.REGISTRY_USERNAME }}
|
||||
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
|
||||
- name: Build and Push Docker Image
|
||||
run: |
|
||||
IMAGE_TAG="${REGISTRY}/${IMAGE_NAME}:staging-${GITHUB_SHA::7}"
|
||||
docker build -t ${IMAGE_TAG} -t ${REGISTRY}/${IMAGE_NAME}:staging .
|
||||
docker push ${IMAGE_TAG}
|
||||
docker push ${REGISTRY}/${IMAGE_NAME}:staging
|
||||
|
||||
- name: Deploy to Swarm
|
||||
run: |
|
||||
docker service update \
|
||||
--image ${REGISTRY}/${IMAGE_NAME}:staging \
|
||||
--with-registry-auth \
|
||||
${SWARM_SERVICE}
|
||||
Reference in New Issue
Block a user