generated from actions/container-action
-
Notifications
You must be signed in to change notification settings - Fork 14
162 lines (136 loc) · 4.19 KB
/
main.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
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
name: CI
on:
push:
branches:
- "main"
tags:
- 'v*.*.*'
pull_request:
branches:
- "main"
jobs:
pretest:
name: Test (with Dockerfile)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Update action.yml to build locally
run: |
sed -i 's/.*image\:.*/ image\: \"Dockerfile\"/' action.yml
cat action.yml
- name: Get sample PKGBUILD
run: wget https://github.com/hapakaien/plenti-bin/raw/f5ffaaee02a2119aa16f6b7a27e87e198e096b47/PKGBUILD
- name: Running test
uses: ./
with:
pkgver: '0.4.26'
pkgrel: 2
updpkgsums: true
srcinfo: true
- name: Show diff
run: |
ls -la
git diff PKGBUILD
git diff .SRCINFO
publish:
name: Publish OCI image
needs: pretest
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Log in to ghcr.io
uses: redhat-actions/podman-login@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: OCI metadata
id: metadata
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=edge,branch=main
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Build image
id: build
uses: redhat-actions/buildah-build@v2
with:
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
containerfiles: |
./Dockerfile
extra-args: |
--pull
- name: Push to ghcr.io
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build.outputs.image }}
tags: ${{ steps.build.outputs.tags }}
registry: ghcr.io
extra-args: |
--disable-content-trust
test:
name: Test (with prebuilt OCI Image)
needs: publish
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get sample PKGBUILD
run: wget https://github.com/hapakaien/plenti-bin/raw/f5ffaaee02a2119aa16f6b7a27e87e198e096b47/PKGBUILD
- name: Update action.yml to use edge tagged container image
if: github.ref == 'refs/heads/main'
run: |
REPOSITORY_OWNER=${{ github.repository_owner }}
REPOSITORY_OWNER=$(echo $REPOSITORY_OWNER | tr '[:upper:]' '[:lower:]')
REPOSITORY_NAME=${{ github.event.repository.name }}
REPOSITORY_NAME=$(echo $REPOSITORY_NAME | tr '[:upper:]' '[:lower:]')
sed -i "s/.*image\:.*/ image\: \"docker\:\/\/ghcr.io\/${REPOSITORY_OWNER}\/${REPOSITORY_NAME}\:edge\"/" action.yml
cat action.yml
- name: Running test
uses: ./
with:
pkgver: '0.4.26'
pkgrel: 2
updpkgsums: true
srcinfo: true
- name: Show diff
run: |
ls -la
git diff PKGBUILD
git diff .SRCINFO
release:
name: Release
runs-on: ubuntu-latest
needs: test
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get branch/tag names
id: branch-name
uses: tj-actions/branch-names@v7
with:
strip_tag_prefix: "v"
- name: Read changelog
id: changelog-reader
uses: mindsers/changelog-reader-action@v2
with:
version: ${{ steps.branch-name.outputs.tag }}
path: ./CHANGELOG.md
- name: Create/update release
uses: ncipollo/release-action@v1
with:
tag: v${{ steps.branch-name.outputs.tag }}
name: v${{ steps.branch-name.outputs.tag }}
body: ${{ steps.changelog-reader.outputs.changes }}
allowUpdates: true
token: ${{ secrets.GITHUB_TOKEN }}