Add OpenCTI Connector Charms #3
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: | |
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 | 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 | |
uses: canonical/craft-actions/rockcraft-pack@main | |
with: | |
path: ${{ steps.rock-dir.outputs.rock-dir }} | |
- 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 | |
uses: canonical/craft-actions/charmcraft/pack@main | |
- 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 && apt install python3-yaml -y | |
- 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/[email protected] | |
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 }} |