Skip to content

Update docker-image.yml #93

Update docker-image.yml

Update docker-image.yml #93

Workflow file for this run

name: Docker Image CI
on:
push:
branches: [ master ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to Github Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Tencent Clouds Registry
uses: docker/login-action@v1
with:
registry: ${{ secrets.TENCENT_YUN_REGISTRY_HOST }}
username: ${{ secrets.TENCENT_YUN_REGISTRY_USERNAME }}
password: ${{ secrets.TENCENT_YUN_REGISTRY_PASSWORD }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
push: true
tags: |
ghcr.io/${{ github.repository }}:latest
${{ secrets.TENCENT_YUN_REGISTRY_HOST }}/${{ github.repository }}:latest
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}:buildcache
cache-to: type=registry,ref=ghcr.io/${{ github.repository }}:buildcache,mode=max
deploy:
if: github.ref_name == 'master'
container: ghcr.io/${{ github.repository }}:deployer
runs-on: ubuntu-latest
environment: PROD
needs: build
env:
REPOSITORY: ${{ github.repository }}
INGRESS_HOST: ${{ secrets.INGRESS_HOST }}
KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }}
FRPC_CONFIG: ${{ secrets.FRPC_CONFIG}}
steps:
- uses: actions/checkout@v2
- name: Deploy to self-hosted server
run: |
# generate kubeconfig
echo "${KUBE_CONFIG}" | base64 -d > kubeconfig.yaml
# render deploy configuration
cat runtime/deployment.yaml | /root/envsubst > /tmp/deployment.yaml
cat runtime/service.yaml | /root/envsubst > /tmp/service.yaml
cat runtime/ingress.yaml | /root/envsubst > /tmp/ingress.yaml
# 部署资源
/root/kubectl --kubeconfig=./kubeconfig.yaml apply -f /tmp/deployment.yaml
/root/kubectl --kubeconfig=./kubeconfig.yaml apply -f /tmp/service.yaml
/root/kubectl --kubeconfig=./kubeconfig.yaml apply -f /tmp/ingress.yaml