rearrange: add workflow for each branch
This commit is contained in:
parent
93d41e8ded
commit
41fc40ac0f
|
|
@ -0,0 +1,56 @@
|
|||
name: Deploy Backend Production Environment
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ prod ]
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
ENV_NAME: prod
|
||||
IMAGE_NAME: csa-backend
|
||||
REGISTRY: ${{ secrets.REGISTRY_URL }}
|
||||
|
||||
jobs:
|
||||
build-and-deploy:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout source code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set image tag
|
||||
run: |
|
||||
echo "IMAGE_TAG=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
|
||||
|
||||
- name: Login to registry
|
||||
run: |
|
||||
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login $REGISTRY \
|
||||
-u "${{ secrets.REGISTRY_USERNAME }}" --password-stdin
|
||||
|
||||
- name: Build and push image
|
||||
run: |
|
||||
docker build -t $REGISTRY/$IMAGE_NAME:$IMAGE_TAG .
|
||||
docker push $REGISTRY/$IMAGE_NAME:$IMAGE_TAG
|
||||
|
||||
- name: Clone manifest repo
|
||||
run: |
|
||||
git clone https://oauth2:${{ secrets.MANIFEST_REPO_TOKEN }}@${{ secrets.MANIFEST_REPO_URL }} manifest
|
||||
cd manifest
|
||||
git checkout (${ENV_NAME})
|
||||
|
||||
- name: Update kustomization (PROD)
|
||||
run: |
|
||||
cd manifest/overlays
|
||||
kustomize edit set image $REGISTRY/$IMAGE_NAME=$REGISTRY/$IMAGE_NAME:$IMAGE_TAG
|
||||
|
||||
- name: Commit manifest update
|
||||
run: |
|
||||
cd manifest
|
||||
git config user.name "csa-ci"
|
||||
git config user.email "ci@gitea.local"
|
||||
git commit -am "deploy(${ENV_NAME}): update backend image to $IMAGE_TAG"
|
||||
git push origin (${ENV_NAME})
|
||||
|
||||
- name: Cleanup workspace
|
||||
run: |
|
||||
rm -rf manifest
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
name: Deploy Backend Production Environment
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ staging ]
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
ENV_NAME: staging
|
||||
IMAGE_NAME: csa-backend
|
||||
REGISTRY: ${{ secrets.REGISTRY_URL }}
|
||||
|
||||
jobs:
|
||||
build-and-deploy:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout source code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set image tag
|
||||
run: |
|
||||
echo "IMAGE_TAG=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
|
||||
|
||||
- name: Login to registry
|
||||
run: |
|
||||
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login $REGISTRY \
|
||||
-u "${{ secrets.REGISTRY_USERNAME }}" --password-stdin
|
||||
|
||||
- name: Build and push image
|
||||
run: |
|
||||
docker build -t $REGISTRY/$IMAGE_NAME:$IMAGE_TAG .
|
||||
docker push $REGISTRY/$IMAGE_NAME:$IMAGE_TAG
|
||||
|
||||
- name: Clone manifest repo
|
||||
run: |
|
||||
git clone https://oauth2:${{ secrets.MANIFEST_REPO_TOKEN }}@${{ secrets.MANIFEST_REPO_URL }} manifest
|
||||
cd manifest
|
||||
git checkout (${ENV_NAME})
|
||||
|
||||
- name: Update kustomization (PROD)
|
||||
run: |
|
||||
cd manifest/overlays
|
||||
kustomize edit set image $REGISTRY/$IMAGE_NAME=$REGISTRY/$IMAGE_NAME:$IMAGE_TAG
|
||||
|
||||
- name: Commit manifest update
|
||||
run: |
|
||||
cd manifest
|
||||
git config user.name "csa-ci"
|
||||
git config user.email "ci@gitea.local"
|
||||
git commit -am "deploy(${ENV_NAME}): update backend image to $IMAGE_TAG"
|
||||
git push origin (${ENV_NAME})
|
||||
|
||||
- name: Cleanup workspace
|
||||
run: |
|
||||
rm -rf manifest
|
||||
Loading…
Reference in New Issue