-
Notifications
You must be signed in to change notification settings - Fork 0
92 lines (87 loc) · 2.94 KB
/
Copy pathexport-layer.yml
File metadata and controls
92 lines (87 loc) · 2.94 KB
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
name: export layer
on:
push:
tags:
- "**"
env:
registry: https://registry.oomol.com
permissions:
contents: read
id-token: write
jobs:
package:
runs-on: ubuntu-latest
outputs:
name: ${{ steps.get_name.outputs.name }}
version: ${{ steps.get_version.outputs.version }}
is-publish: ${{ steps.is_publish.outputs.result }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get name
id: get_name
run: |
if [ -f package.oo.yaml ]; then
name=$(yq eval '.name' package.oo.yaml)
echo "name=$name" >> "$GITHUB_OUTPUT"
elif [ -f package.oo.yml ]; then
name=$(yq eval '.name' package.oo.yml)
echo "name=$name" >> "$GITHUB_OUTPUT"
else
echo "No valid package file found"
exit 1
fi
- name: Get version
id: get_version
run: |
if [ -f package.oo.yaml ]; then
version=$(yq eval '.version' package.oo.yaml)
echo "version=$version" >> "$GITHUB_OUTPUT"
elif [ -f package.oo.yml ]; then
version=$(yq eval '.version' package.oo.yml)
echo "version=$version" >> "$GITHUB_OUTPUT"
else
echo "No valid package file found"
exit 1
fi
- name: publish
id: is_publish
run: |
http_status=$(curl -s -o /dev/null -w "%{http_code}" "${{env.registry}}/-/oomol/detail/${{ steps.get_name.outputs.name }}/${{ steps.get_version.outputs.version }}")
if [ "$http_status" -eq 404 ]; then
echo "Package not found, proceeding to publish."
echo "result=false" >> "$GITHUB_OUTPUT"
elif [ "$http_status" -eq 200 ]; then
echo "Package already exists (HTTP status: $http_status), skipping publish."
echo "result=true" >> "$GITHUB_OUTPUT"
else
echo "Error checking package existence (HTTP status: $http_status). Assuming it doesn't exist."
exit 1
fi
publish:
runs-on: ubuntu-latest
needs: [package]
steps:
- name: Checkout code
uses: actions/checkout@v4
if: needs.package.outputs.is-publish == 'false'
- name: Set up Node.js
uses: actions/setup-node@v4
if: needs.package.outputs.is-publish == 'false'
- name: Install oopm
run: npm install -g oopm
if: needs.package.outputs.is-publish == 'false'
- name: Publish OOMOL Package
uses: oomol-lab/oopm-publish-action@main
if: needs.package.outputs.is-publish == 'false'
export-layer:
needs: [package, publish]
permissions:
contents: read
id-token: write
uses: oomol/ovmlayer-rootfs/.github/workflows/export-package-layer.yml@main
with:
package-name: ${{ needs.package.outputs.name }}
version: "${{ needs.package.outputs.version }}"
secrets:
token: ${{ secrets.GITHUB_TOKEN }}