You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.3 KiB
44 lines
1.3 KiB
name: Docker Image CI
|
|
on:
|
|
push:
|
|
branches: [ master ]
|
|
pull_request:
|
|
branches: [ master ]
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v2 # 获取仓库的代码文件
|
|
- name: Set up JDK
|
|
uses: actions/setup-java@v1
|
|
with:
|
|
java-version: 1.11
|
|
- name: Build with Maven
|
|
run: mvn clean install
|
|
- name: Build the Docker image
|
|
run: |
|
|
docker login --username=${{ secrets.DOCKER_USER }} --password=${{ secrets.DOCKER_PASSWORD }}
|
|
docker build . --file Dockerfile --tag evolonation/cicd-test:${{ github.sha }}
|
|
docker push evolonation/cicd-test:${{ github.sha }}
|
|
# k8s部署
|
|
- run: |
|
|
sed -i 's/{TAG}/${{ github.sha }}/g' deployment.yaml
|
|
- name: k8s deployment
|
|
uses: steebchen/kubectl@v2.0.0
|
|
with:
|
|
config: ${{ secrets.KUBE_CONFIG }}
|
|
version: v1.26.0
|
|
command: apply -f deployment.yaml
|
|
- name: k8s service
|
|
uses: steebchen/kubectl@v2.0.0
|
|
with:
|
|
config: ${{ secrets.KUBE_CONFIG }}
|
|
version: v1.26.0
|
|
command: apply -f service.yaml
|
|
- name: deployment status
|
|
uses: steebchen/kubectl@v2.0.0
|
|
with:
|
|
config: ${{ secrets.KUBE_CONFIG }}
|
|
version: v1.26.0
|
|
command: rollout status deployment/cicd-test |