-
Notifications
You must be signed in to change notification settings - Fork 0
93 lines (82 loc) · 2.85 KB
/
ci.yaml
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
name: ci
on:
push:
branches:
- 'main'
jobs:
build-and-push-image:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get Version
id: version
run: |
set -x
echo "VERSION=$(python apps/version.py)" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/g10f/oauth-python-sample
tags: |
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }}
type=pep440,pattern={{version}},value=${{ steps.version.outputs.VERSION }}
type=sha
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# with:
# driver-opts: image=moby/buildkit:master
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
deploy:
needs: build-and-push-image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
repository: g10f/deployment
ref: main
token: ${{ secrets.PAT }}
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-central-1
- run: |
curl "https://s3.amazonaws.com/session-manager-downloads/plugin/latest/ubuntu_64bit/session-manager-plugin.deb" -o "session-manager-plugin.deb"
sudo dpkg -i session-manager-plugin.deb
- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_KEY }}
known_hosts: ${{ secrets.KNOWN_HOSTS }}
config: |
Host g10f-oidc-demo
ProxyCommand sh -c "aws ssm start-session --region eu-central-1 --target ${{ secrets.INSTANCE_ID }} --document-name AWS-StartSSHSession --parameters 'portNumber=%p'"
User ubuntu
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- run: |
pip install -r requirements.txt
ansible-playbook deploy.yml -D -l g10f-oidc-demo -t update
env:
ANSIBLE_VAULT_IDENTITY_LIST: vault-password-file.sh
ANSIBLE_VAULT_PASSWORD: ${{ secrets.ANSIBLE_VAULT_PASSWORD }}