Add OpenCTI Connector Charms #7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish to edge | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
jobs: | |
find-charms: | |
name: Find Charms | |
runs-on: ubuntu-latest | |
outputs: | |
charm-dirs: ${{ steps.charm-dirs.outputs.charm-dirs }} | |
steps: | |
- uses: actions/checkout@v4 | |
- id: charm-dirs | |
run: | | |
echo charm-dirs=`find -name charmcraft.yaml | xargs dirname | jq --raw-input --slurp 'split("\n") | map(select(. != ""))'` >> $GITHUB_OUTPUT | |
publish-charm: | |
needs: [ find-charms ] | |
strategy: | |
matrix: | |
charm-dir: ${{ fromJSON(needs.find-charms.outputs.charm-dirs) }} | |
name: Publish Charm (${{ matrix.charm-dir }}) | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: change directory | |
run: | | |
TEMP_DIR=$(mktemp -d) | |
cp -rp ./${{ matrix.charm-dir }}/. $TEMP_DIR | |
rm -rf .* * || : | |
cp -rp $TEMP_DIR/. . | |
rm -rf $TEMP_DIR | |
- name: find rock | |
id: rock-dir | |
run: | | |
echo rock-dir=`dirname *rock/rockcraft.yaml` >> $GITHUB_OUTPUT | |
- name: build rock | |
id: rockcraft | |
run: | | |
sudo snap install lxd | |
sudo lxd init --auto | |
sudo iptables -P FORWARD ACCEPT | |
sudo snap install --channel stable --classic rockcraft | |
cd ${{ steps.rock-dir.outputs.rock-dir }} | |
rockcraft pack --verbosity trace | |
echo rock=`ls *.rock` >> $GITHUB_OUTPUT | |
- run: | | |
echo rockcraft pack: | |
echo ${{ steps.rockcraft.outputs.rock }} | |
- name: upload rock | |
run: | | |
rockcraft.skopeo --insecure-policy copy --dest-tls-verify=false oci-archive:${{ steps.rockcraft.outputs.rock }} docker-daemon:rock:latest | |
- name: build charm | |
id: charmcraft | |
run: | |
sudo snap install --channel stable --classic charmcraft | |
charmcraft pack --verbosity trace | |
echo charms=`ls *.charm` >> $GITHUB_OUTPUT | |
- run: | | |
echo charmcraft pack: | |
echo ${{ steps.charmcraft.outputs.charms }} | |
- id: charm-name | |
run: | | |
echo charm-name=`yq -r .name charmcraft.yaml` >> $GITHUB_OUTPUT | |
- run: | | |
sudo apt update && sudo apt install python3-yaml -y | |
- name: update upstream-source | |
shell: python | |
run: | | |
import yaml | |
charmcraft_yaml = yaml.safe_load(open("charmcraft.yaml")) | |
resources = charmcraft_yaml["resources"] | |
resources[list(resources)[0]]["upstream-source"] = "rock:latest" | |
yaml.dump(charmcraft_yaml, open("charmcraft.yaml", "w"), sort_keys=False) | |
- run: | | |
echo upload charm ${{ steps.charm-name.outputs.charm-name }} | |
- run: | | |
cat charmcraft.yaml | |
- if: github.event_name == 'push' | |
name: publish charm | |
uses: canonical/charming-actions/upload-charm@2.6.3 | |
with: | |
credentials: ${{ secrets.CHARMHUB_TOKEN }} | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
built-charm-path: ${{ steps.charmcraft.outputs.charms }} | |
tag-prefix: ${{ steps.charm-name.outputs.charm-name }} |