- name:Update the API serviceuses:appleboy/ssh-action@v0.0.6with:host:${{ secrets.ssh_host }}username:deploykey:${{ secrets.ssh_key }}script_stop:truescript:| cd golang && docker-compose pull && docker-compose up -d
name:Build and Teston:push:branches:- masterpull_request:jobs:build:strategy:matrix:platform:[ubuntu-latest]runs-on:${{ matrix.platform }}steps:- name:Install Gouses:actions/setup-go@v1with:go-version:${{ matrix.go-version }}- name:Check out codeuses:actions/checkout@v1- name:Tesingrun:| make test- name:Build binaryrun:| make build_linux_amd64- name:Publish to Registryuses:elgohr/Publish-Docker-Github-Action@2.9with:name:appleboy/helloworldusername:appleboypassword:${{ secrets.docker_password }}dockerfile:docker/helloworld/Dockerfile.linux.amd64- name:Update the API serviceuses:appleboy/ssh-action@v0.0.6with:host:${{ secrets.ssh_host }}username:deploykey:${{ secrets.ssh_key }}script_stop:truescript:| cd golang && docker-compose pull && docker-compose up -d
使用容器當做基底
從上面的設定檔我會有個疑問,就是每一個 Job 都要從最初始化安裝環境,像上面就是安裝 Go 語言環境。那能不能直接選用 Go 官方提供的容器當作基底,這樣就可以少裝一個步驟,答案是可以的,每一個 Job 都可以指定不同的容器來啟動