-
Notifications
You must be signed in to change notification settings - Fork 0
134 lines (126 loc) · 4.24 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: CI
on:
push:
tags-ignore:
- "*"
branches:
- "main"
pull_request:
release:
types: [published]
workflow_dispatch:
jobs:
ansible-lint:
name: Playbook linting
runs-on: ubuntu-20.04
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install galaxy deps
run: ansible-galaxy install -r demo-idp/requirements.yml
- name: Run ansible-lint
uses: ansible/[email protected]
build-and-push-container-images-demo-idp:
name: Build and push container images for demo-idp playbook
runs-on: ubuntu-20.04
if: github.event_name == 'release' || (github.event_name == 'push' && github.ref_name == 'main')
needs: [ansible-lint]
permissions:
contents: read
packages: write
env:
REGISTRY: ghcr.io
IMAGE_REPOSITORY: ghcr.io/${{ github.repository_owner }}/werkzeugkoffer-demo-idp
IMAGE_TAG: "${{ (github.event_name == 'release' && github.event.release.tag_name) || (github.event_name == 'push' && github.ref_name == 'main' && 'rolling') || github.sha }}"
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: docker/setup-buildx-action@v2
- name: Log in to the Container registry
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@507c2f2dc502c992ad446e3d7a5dfbe311567a96
with:
images: ${{ env.IMAGE_REPOSITORY }}
- name: Build and push container image
uses: docker/build-push-action@v4
with:
context: ./demo-idp
file: "demo-idp/docker/Dockerfile"
push: true
tags: ${{ env.IMAGE_REPOSITORY }}:${{ env.IMAGE_TAG }}
labels: ${{ steps.meta.outputs.labels }}
platforms: "linux/amd64,linux/arm64"
cache-from: type=gha
cache-to: type=gha,mode=max
create-artifact-demo-idp:
runs-on: ubuntu-20.04
needs: [ansible-lint]
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Compress tarball
run: |
tar -zcf werkzeugkoffer-demo-idp.tgz demo-idp/roles/ demo-idp/playbook.yml demo-idp/playbook.cleanup.yml demo-idp/requirements.yml demo-idp/README.md
- uses: actions/upload-artifact@v3
with:
name: werkzeugkoffer-demo-idp
path: |
*.tgz
release-rolling-demo-idp:
runs-on: ubuntu-20.04
if: (github.event_name == 'push' && github.ref == 'refs/heads/main')
needs: [create-artifact-demo-idp]
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- uses: actions/download-artifact@v3
with:
name: werkzeugkoffer-demo-idp
- uses: "marvinpinto/[email protected]"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "rolling"
prerelease: true
title: "Cutting Edge"
files: |
werkzeugkoffer-demo-idp.tgz
release-demo-idp:
runs-on: ubuntu-20.04
if: github.event.release
needs: [create-artifact-demo-idp]
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- uses: actions/download-artifact@v3
with:
name: werkzeugkoffer-demo-idp
- uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: werkzeugkoffer-demo-idp.tgz
tag: ${{ github.ref }}