Skip to content

Commit

Permalink
chore: split files
Browse files Browse the repository at this point in the history
  • Loading branch information
M7mdisk committed Aug 23, 2024
1 parent 0b87046 commit ed6c78f
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 34 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/publish-charm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Pack and Publish Charm

on:
push:
branches:
- charming-charmhub # TODO: Change this to main once we are ready to deploy
paths:
- 'charm/**' # Only trigger when changes are made to the ./charm/ directory

env:
CHARMCRAFT_ENABLE_EXPERIMENTAL_EXTENSIONS: true

jobs:
pack-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

Original file line number Diff line number Diff line change
@@ -1,44 +1,23 @@
name: Build and publish charm
name: Pack Rock and Publish Image

on:
push:
branches:
- charming-charmhub # TODO(mhdisk): Change this to main once we are ready to deploy
- charming-charmhub # TODO: Change this to main once we are ready to deploy
# paths:
# - '.env'
# - 'app.py'
# - 'webapp'
# - 'templates'
# - 'static'
# - 'redirects.yaml'

env:
CHARMCRAFT_ENABLE_EXPERIMENTAL_EXTENSIONS: true
ROCKCRAFT_ENABLE_EXPERIMENTAL_EXTENSIONS: true

jobs:
pack-charm:
# only run when ./charm content changes
- path:
- '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
Expand Down Expand Up @@ -84,7 +63,7 @@ jobs:
- 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
- name: Pull image into registry
run: docker pull ${{ steps.set_image_url.outputs.image_url }}

- name: Upload flask app OCI image
Expand All @@ -93,11 +72,12 @@ jobs:
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=$(charmcraft revisions charmhub-io | awk 'NR==2 {print $1}')
resource_revision_number=$(charmcraft resource-revisions charmhub-io flask-app-image | awk 'NR==2 {print $1}')
charmcraft release charmhub-io --channel=beta --revision $revision_number --resource flask-app-image:$resource_revision_number

0 comments on commit ed6c78f

Please sign in to comment.