- 在线文档部署源码
- Ansible入门系列视频:
B站 https://space.bilibili.com/364122352/channel/detail?cid=125322build.yml文件
name: docker image build and pushon: [push]jobs:build:runs-on: ubuntu-lateststeps:- name: Checkoutuses: actions/checkout@v2- name: Set up QEMUuses: docker/setup-qemu-action@v1- name: Set up Docker Buildxid: buildxuses: docker/setup-buildx-action@v1- name: Login to DockerHubuses: docker/login-action@v1with:username: ${{ secrets.DOCKERHUB_USERNAME }}password: ${{ secrets.DOCKERHUB_PASSWORD }}- name: Build and pushid: docker_builduses: docker/build-push-action@v2with:push: trueplatforms: linux/amd64,linux/arm64tags: insaneloafer/dockertips:latestdeploy:runs-on: ubuntu-latestneeds: buildsteps:- name: Checkoutuses: actions/checkout@v2- name: deploy to awsrun: |cd ansible/pip install ansibleecho ${{ secrets.ANSIBLE_VAULT }} > vault_pass.txtexport ANSIBLE_VAULT_PASSWORD_FILE=vault_pass.txtansible-vault decrypt aws.pemansible-playbook -i hosts deploy.yml
deploy.yml 文件
``` - name: deploy docker.tips
hosts: aws
gather_facts: no
vars:
ansible_connection: ssh
ansible_user: ubuntu
ansible_ssh_private_key_file: ./aws.pem
tasks:
- name: stop the old container shell: docker container stop web ignore_errors: yes
- name: update docker image shell: docker image pull InsaneLoafer/dockertips:latest
- name: create new container shell: docker container run —rm -d -p 80:80 —name web InsaneLoafer/dockertips:latest ```
