Test auto-deploy
This commit is contained in:
75
.github/workflows/kub-deploy.yml
vendored
75
.github/workflows/kub-deploy.yml
vendored
@@ -6,7 +6,7 @@ on:
|
|||||||
- kub-stage
|
- kub-stage
|
||||||
|
|
||||||
env:
|
env:
|
||||||
REGISTRY: 194.5.195.53:30080
|
REGISTRY: gitea-svc:3000
|
||||||
IMAGE_NAME: admin/frontoffice-bff
|
IMAGE_NAME: admin/frontoffice-bff
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
@@ -19,30 +19,73 @@ jobs:
|
|||||||
HTTP_PROXY: http://proxyuser:87zH26nbqT2@46.249.98.211:3128
|
HTTP_PROXY: http://proxyuser:87zH26nbqT2@46.249.98.211:3128
|
||||||
HTTPS_PROXY: http://proxyuser:87zH26nbqT2@46.249.98.211:3128
|
HTTPS_PROXY: http://proxyuser:87zH26nbqT2@46.249.98.211:3128
|
||||||
NO_PROXY: localhost,127.0.0.1,gitea-svc,194.5.195.53,10.0.0.0/8
|
NO_PROXY: localhost,127.0.0.1,gitea-svc,194.5.195.53,10.0.0.0/8
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Install git
|
- name: Install dependencies
|
||||||
run: apk add --no-cache git
|
run: |
|
||||||
|
apk add --no-cache git curl
|
||||||
|
|
||||||
- name: Clone repository
|
# Install kubectl
|
||||||
run: git clone --depth 1 --branch kub-stage http://gitea-svc:3000/admin/FrontOffice.BFF.git .
|
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
|
||||||
|
chmod +x kubectl
|
||||||
|
mv kubectl /usr/local/bin/
|
||||||
|
|
||||||
- name: Start Docker daemon
|
- name: Start Docker daemon with insecure registry
|
||||||
run: |
|
run: |
|
||||||
mkdir -p /etc/docker
|
mkdir -p /etc/docker
|
||||||
echo '{"insecure-registries": ["194.5.195.53:30080"]}' > /etc/docker/daemon.json
|
cat > /etc/docker/daemon.json << 'DAEMON'
|
||||||
|
{
|
||||||
|
"insecure-registries": ["194.5.195.53:30080", "gitea-svc:3000"]
|
||||||
|
}
|
||||||
|
DAEMON
|
||||||
|
mkdir -p ~/.docker
|
||||||
|
cat > ~/.docker/config.json << 'CONF'
|
||||||
|
{
|
||||||
|
"proxies": {
|
||||||
|
"default": {
|
||||||
|
"httpProxy": "http://proxyuser:87zH26nbqT2@46.249.98.211:3128",
|
||||||
|
"httpsProxy": "http://proxyuser:87zH26nbqT2@46.249.98.211:3128",
|
||||||
|
"noProxy": "localhost,127.0.0.1,gitea-svc,194.5.195.53,10.0.0.0/8"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CONF
|
||||||
dockerd &
|
dockerd &
|
||||||
for i in $(seq 1 30); do docker info >/dev/null 2>&1 && break || sleep 2; done
|
for i in $(seq 1 30); do
|
||||||
|
docker info >/dev/null 2>&1 && break || sleep 2
|
||||||
|
done
|
||||||
|
docker info
|
||||||
|
|
||||||
|
- name: Checkout code
|
||||||
|
run: |
|
||||||
|
git clone --depth 1 --branch kub-stage http://gitea-svc:3000/admin/FrontOffice.BFF.git .
|
||||||
|
git log -1 --format="%H %s"
|
||||||
|
|
||||||
- name: Build Docker Image
|
- name: Build Docker Image
|
||||||
run: |
|
run: |
|
||||||
docker build -t $REGISTRY/$IMAGE_NAME:${{ github.sha }} \
|
cd src
|
||||||
-t $REGISTRY/$IMAGE_NAME:latest \
|
docker build -f FrontOffice.BFF.WebApi/Dockerfile \
|
||||||
--build-arg HTTP_PROXY=$HTTP_PROXY \
|
-t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} \
|
||||||
--build-arg HTTPS_PROXY=$HTTPS_PROXY .
|
-t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest \
|
||||||
|
--build-arg HTTP_PROXY=http://proxyuser:87zH26nbqT2@46.249.98.211:3128 \
|
||||||
|
--build-arg HTTPS_PROXY=http://proxyuser:87zH26nbqT2@46.249.98.211:3128 \
|
||||||
|
.
|
||||||
|
|
||||||
|
|
||||||
- name: Push to Registry
|
- name: Push to Registry
|
||||||
run: |
|
run: |
|
||||||
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login $REGISTRY -u admin --password-stdin
|
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login ${{ env.REGISTRY }} -u admin --password-stdin
|
||||||
docker push $REGISTRY/$IMAGE_NAME:${{ github.sha }}
|
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
|
||||||
docker push $REGISTRY/$IMAGE_NAME:latest
|
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
|
||||||
|
|
||||||
|
- name: Deploy to Kubernetes
|
||||||
|
run: |
|
||||||
|
# Setup kubeconfig
|
||||||
|
mkdir -p ~/.kube
|
||||||
|
echo "${{ secrets.KUBECONFIG }}" | base64 -d > ~/.kube/config
|
||||||
|
|
||||||
|
# Restart deployment to pull new image
|
||||||
|
kubectl rollout restart deployment/frontOffice-bff || echo "Deployment doesn't exist yet"
|
||||||
|
|
||||||
|
# Wait for rollout to complete
|
||||||
|
kubectl rollout status deployment/frontOffice-bff --timeout=5m || echo "Deployment rollout pending"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user