-
Notifications
You must be signed in to change notification settings - Fork 1
66 lines (54 loc) · 1.81 KB
/
cd.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
name: Continuous Deployment
on:
push:
branches: [ main ]
jobs:
docker_push:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
# GitHub Actions do not expose the commit date, so we need to
# store it in an env variable ourselves.
- name: Get commit date
id: git_commit_date
run: "echo GIT_COMMIT_DATE=$(git log -1 --format=%cd --date=iso-strict ${{ github.sha }}) >> $GITHUB_ENV"
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: tactilenews/hundred-eyes:latest
build-args: |
git_commit_sha=${{ github.sha }}
git_commit_date=${{ env.GIT_COMMIT_DATE }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
deploy:
needs: [docker_push]
runs-on: ubuntu-latest
concurrency: staging_environment
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Run playbook
uses: dawidd6/action-ansible-playbook@009b88e9b8894bd8838475d799b7dca5024e91d5
with:
playbook: ansible/site.yml
requirements: ansible/requirements.yml
key: ${{secrets.SSH_PRIVATE_KEY}}
vault_password: ${{secrets.VAULT_PASSWORD}}
options: |
--inventory ansible/inventories/staging
--skip-tags skip_ci
--verbose