/charming-actions

A collection of Github Actions for interaction with Charmhub, and validating Charmed Operator code

Primary LanguageTypeScript

Charming Actions Collection

The Charming Actions Collection is a set of actions useful for Juju charm developers who want to introduce automation into their release workflow. The collection currently consists of the following actions:

Usage

⚠️ Prerequisites

To use this action, start by adding a repository secret to your Github repository. In the example below, it's called CHARMCRAFT_TOKEN, but can be anything you want. See https://juju.is/docs/sdk/remote-env-auth for more information on how to generate the appropriate credentials. GITHUB_TOKEN does not need to be explicitly added to the repository secrets as GitHub Actions will generate a context-bound token for each workflow execution.

The below snippet illustrates how to use the actions of the collection in a PR workflow, as well as a push workflow:

name: Pull Request

on: 
  pull_request:
    branches:
      - main

jobs:
  build:
    name: Release to edge
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
        with:
          fetch-depth: 0  
      - name: Check libraries
        uses: canonical/charming-actions/check-libraries@2.2.0
        with:
          credentials: "${{ secrets.CHARMHUB_TOKEN }}"
          github-token: "${{ secrets.GITHUB_TOKEN }}"
name: Release

on:
  push:
    branches:
      - main

jobs:
  build:
    name: Release
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - name: Release any bumped charm libs
        uses: canonical/charming-actions/release-libraries@2.2.0
        with:
          credentials: "${{ secrets.CHARMHUB_TOKEN }}"
          github-token: "${{ secrets.GITHUB_TOKEN }}"
      - name: Select charmhub channel
        uses: canonical/charming-actions/channel@2.2.0
        id: channel
      - name: Upload charm to charmhub
        uses: canonical/charming-actions/upload-charm@2.2.0
        with:
          credentials: "${{ secrets.CHARMHUB_TOKEN }}"
          github-token: "${{ secrets.GITHUB_TOKEN }}"
          upload-image: "true"
          channel: "${{ steps.channel.outputs.name }}"

Development

To be able to contribute to this repository, you first need to make sure you have npm and nodejs installed in your local development environment. This installation varies depending on the OS and distribution you are using. For more detailed instructions, see the official NodeJS page.

Once that is done, start by cloning the repository:

$ git clone git@github.com:canonical/charming-actions.git
$ cd charming-actions

Then install the required packages:

$ npm install

Finally, build the actions by running:

$ npm run build

Tests

Run unit tests:

$ npm test