-
Notifications
You must be signed in to change notification settings - Fork 0
98 lines (82 loc) · 2.22 KB
/
release.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
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
name: Release
concurrency:
group: release-${{ github.repository }}
on:
pull_request:
branches:
- main
push:
tags:
- 'v*'
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Check out repo
uses: actions/checkout@v3
with:
fetch-depth: 1
path: .
- name: Set up Buildx
uses: docker/setup-buildx-action@v2
- name: Build/load image
uses: docker/build-push-action@v4
with:
context: .
file: ./Containerfile
push: false
load: true
tags: "container-ansible:test"
- name: Run image
working-directory: .
run: |
docker run --name test-container -d --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro container-ansible:test
- name: Test image
working-directory: .
run: |
docker exec --tty test-container env TERM=xterm ansible --version
release:
name: Release
runs-on: ubuntu-latest
needs:
- test
if: ${{ startsWith(github.event.ref, 'refs/tags/v') }}
permissions:
contents: read
packages: write
steps:
- name: Check out repo
uses: actions/checkout@v3
with:
fetch-depth: 1
path: .
- name: Log in to GitHub CR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- id: metadata
name: Gather image metadata
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Buildx
uses: docker/setup-buildx-action@v2
- name: Release image
uses: docker/build-push-action@v4
with:
context: .
file: ./Containerfile
push: true
labels: ${{ steps.metadata.outputs.labels }}
tags: ${{ steps.metadata.outputs.tags }}