-
Notifications
You must be signed in to change notification settings - Fork 23
103 lines (84 loc) · 3.16 KB
/
publish_charm.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
name: Build and publish charm
on:
push:
branches:
- charming-charmhub # TODO(mhdisk): Change this to main once we are ready to deploy
env:
CHARMCRAFT_ENABLE_EXPERIMENTAL_EXTENSIONS: true
ROCKCRAFT_ENABLE_EXPERIMENTAL_EXTENSIONS: true
jobs:
pack-charm:
# only run when ./charm content changes
if: ${{ github.event_name == 'push' && contains(github.event.commits.*.added, 'charm') || contains(github.event.commits.*.modified, 'charm') }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup LXD
uses: canonical/setup-lxd@main
- name: Setup charmcraft
run: sudo snap install charmcraft --classic --channel=latest/edge
- name: Fetch libs
run: |
cd ./charm
charmcraft fetch-libs
- name: Pack charm
run: charmcraft pack -v --project-dir ./charm
- name: Upload charm
env:
CHARMCRAFT_AUTH: ${{ secrets.CHARMHUB_TOKEN }}
run: charmcraft upload ./*.charm
pack-rock:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
- name: Build assets
run: |
yarn install
yarn run build
- name: Setup LXD
uses: canonical/setup-lxd@main
- name: Setup rockcraft
run: sudo snap install rockcraft --classic --channel=latest/edge
- name: Pack rock
run: rockcraft pack
- name: Upload rock
uses: actions/upload-artifact@v3
with:
name: charmhub-io-rock
path: ./*.rock
publish-image:
runs-on: ubuntu-latest
needs: pack-rock
outputs:
image_url: ${{ steps.set_image_url.outputs.image_url }}
steps:
- name: Get Rock
uses: actions/download-artifact@v3
with:
name: charmhub-io-rock
- name: Set image URL
id: set_image_url
run: echo "image_url=ghcr.io/canonical/charmhub.io:$(date +%s)-${GITHUB_SHA:0:7}" >> $GITHUB_OUTPUT
- name: Push to GHCR
run: skopeo --insecure-policy copy oci-archive:$(ls *.rock) docker://${{ steps.set_image_url.outputs.image_url }} --dest-creds "canonical:${{ secrets.GITHUB_TOKEN }}"
- name: pull image into registry
run: docker pull ${{ steps.set_image_url.outputs.image_url }}
- name: Upload flask app OCI image
env:
CHARMCRAFT_AUTH: ${{ secrets.CHARMHUB_TOKEN }}
id: upload-flask-app-image
run: |
sudo snap install charmcraft --classic --channel=latest/edge
charmcraft upload-resource charmhub-io flask-app-image --image=`docker images --format "{{.ID}}" | head -n 1` --verbosity=trace
- name: Attach resource to charm
env:
CHARMCRAFT_AUTH: ${{ secrets.CHARMHUB_TOKEN }}
run: |
revision_number=$(grep -oP "Revision \K\d+" <<< "${{ steps.log_step.outputs.log }}")
echo "Latest revision number: $revision_number"
echo "::set-output name=revision::$revision_number"
charmcraft release charmhub-io --channel=beta --resource flask-app-image:$revision_number