Git Product home page Git Product logo

craft-actions's Introduction

Test the action

Craft Actions

This project contains custom GitHub actions for Craft Applications, such as:

The following sections will break down the different actions available in this repository and how to use them.

rockcraft-pack

Can be used to build a rock (with Rockcraft). It expects a "rockcraft.yaml" file to exist in its execution path.

Usage

steps:
  - uses: actions/checkout@v3
  - uses: canonical/craft-actions/rockcraft-pack@main

This will install and configure LXD and Rockcraft, and then invoke rockcraft to build a new rock, based on a "rockcraft.yaml" file located in the root of the workspace.

You can also upload the resulting rock as a GitHub artifact as follows:

steps:
  - uses: actions/checkout@v3
  - uses: canonical/craft-actions/rockcraft-pack@main
    id: rockcraft
  - uses: actions/upload-artifact@v3
    with:
      name: rock
      path: ${{ steps.rockcraft.outputs.rock }}

Additionally, any following steps will already have Rockcraft available for direct invocation through the shell.

Inputs

path

If your Rockcraft project ("rockcraft.yaml") is not located in the root of the workspace, you can specify an alternative location via the path input parameter.

steps:
  - uses: actions/checkout@v3
  - uses: canonical/craft-actions/rockcraft-pack@main
    with:
      path: path/to/rockcraft/project/
verbosity

This verbosity input parameter can be used to set the build verbosity level to one of 'quiet', 'brief', 'verbose', 'debug' or 'trace' (the default).

steps:
  - uses: actions/checkout@v3
  - uses: canonical/craft-actions/rockcraft-pack@main
    with:
      verbosity: debug

Committing code

Please follow these guidelines when committing code for this project:

  • Use a topic with a colon to start the subject
  • Separate subject from body with a blank line
  • Limit the subject line to 50 characters
  • Do not capitalize the subject line
  • Do not end the subject line with a period
  • Use the imperative mood in the subject line
  • Wrap the body at 72 characters
  • Use the body to explain what and why (instead of how)

craft-actions's People

Contributors

liushuyu avatar cjdcordeiro avatar renovate[bot] avatar addyess avatar lengau avatar sergiusens avatar weiiwang01 avatar

Stargazers

Rudra Pratap Singh avatar

Watchers

Claudio Matsuoka avatar James Cloos avatar  avatar Tiago Nobrega avatar  avatar  avatar Dariusz Duda avatar  avatar

craft-actions's Issues

[Feature Request] Publish rock to Github's Container Registry

OVERVIEW

First, good job on the project and the rockcraft-pack action, it' will definitely be useful.

As more people and teams are building rocks, we also have to publish them somewhere. One of the registries used to publish such container images is Github's container registry. Right now, this is a great place to publish container images as it is well integrated with Github where our code, CI and permissions are already managed. Here the ask is for a new action to publish the created rock to Github's container registry.

This action would fetch the artifact created by the rockcraft-pack action, login to ghcr.io, use skopeo to copy the file to docker-daemon and push it to ghcr.io.

Usage

In terms of API, this could look something like:

    steps:
      - name: Checkout repository
        uses: actions/checkout@v3
      - uses: canonical/craft-actions/rockcraft-publish-ghcr@main
        with: 
          artifact_name: rock
          image_name: banana
          image_version: 1.1.1
          organization: canonical

For this example, the action would have published the container image to ghcr.io/canonical/banana:1.1.1. image_name and image_version could default to values read from rockcraft.yaml and organization could default to canonical so that a minimal API could be:

    steps:
      - name: Checkout repository
        uses: actions/checkout@v3
      - uses: canonical/craft-actions/rockcraft-publish-ghcr@main
        with: 
          artifact_name: rock

Current state

Here's what I have to do right now to take the provided rock and publish it to ghcr.io:

    steps:
      - name: Checkout repository
        uses: actions/checkout@v3

      - name: Log in to the Container registry
        uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}

      - name: Install skopeo
        run: |
          sudo snap install --devmode --channel edge skopeo

      - name: Install yq
        run: |
          sudo snap install yq

      - uses: actions/download-artifact@v3
        with:
          name: rock

      - name: Import and push to github package
        run: |
          image_name="$(yq '.name' rockcraft.yaml)"
          version="$(yq '.version' rockcraft.yaml)"
          rock_file=$(ls *.rock | tail -n 1)
          sudo skopeo \
            --insecure-policy \
            copy \
            oci-archive:"${rock_file}" \
            docker-daemon:"ghcr.io/gruyaume/${image_name}:${version}"
          docker push ghcr.io/gruyaume/${image_name}:${version}

Reference

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Awaiting Schedule

These updates are awaiting their schedule. Click on a checkbox to get an update now.

  • chore(deps): update development dependencies (minor and patch) (@types/node, esbuild, eslint-plugin-prettier, prettier, ts-jest, typescript, typescript-eslint)
  • chore(deps): update dependency @types/node to v20
  • chore(deps): update dependency eslint-plugin-github to v5

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/test.yml
  • actions/checkout v4
  • actions/setup-node v4
  • actions/checkout v4
  • actions/upload-artifact v3
  • ubuntu 22.04
npm
package.json
  • @actions/core ^1.10.1
  • @actions/exec ^1.1.1
  • @tsconfig/node18 ^18.2.4
  • @types/jest ^29.5.12
  • @types/node ^18.11.9
  • esbuild ^0.21.0
  • eslint ^8.57.0
  • eslint-plugin-github ^4.10.2
  • eslint-plugin-jest ^28.2.0
  • eslint-plugin-prettier ^5.1.3
  • jest ^29.7.0
  • jest-circus ^29.7.0
  • prettier ^3.2.5
  • ts-jest ^29.1.2
  • typescript ^5.4.5
  • typescript-eslint ^7.7.1
  • node >=18

  • Check this box to trigger a request for Renovate to run again on this repository

Issues installing LXD

Hello team,

This action installs lxd when installing Rockcraft dependencies.
I see in the code that it's trying to install lxd version 5.9/stable

// Install a specific version of LXD that we know works well with Rockcraft
  const haveSnapLXD = await haveExecutable('/snap/bin/lxd')
  core.info('Installing LXD...')
  await exec.exec('sudo', [
    'snap',
    haveSnapLXD ? 'refresh' : 'install',
    'lxd',
    '--channel',
    '5.9/stable'
  ])

However I'm getting the following error when using this action in our ci:

Installing Rockcraft plus dependencies
  Ensuring runner is in the lxd group...
  /usr/bin/sudo groupadd --force --system lxd
  /usr/bin/sudo usermod --append --groups lxd runner
  Installing LXD...
  /usr/bin/sudo snap refresh lxd --channel 5.[9](https://github.com/canonical/magma-nms-magmalte-rock/actions/runs/4544227705/jobs/8013031187?pr=2#step:3:10)/stable
  error: snap "lxd" is not available on 5.9/stable but is available to install on
         the following channels:
  
         5.9/candidate  snap refresh --channel=5.9/candidate lxd
         5.9/beta       snap refresh --channel=5.9/beta lxd
         5.9/edge       snap refresh --channel=5.9/edge lxd
  
         Please be mindful pre-release channels may include features not
         completely tested or implemented. Get more information with 'snap info
         lxd'.
  Error: The process '/usr/bin/sudo' failed with exit code 1

I tried to install that specific version of lxd manually and I got the same error.

[Feature Request] Add `name`, `version`, `arch` and any other useful metadata as outputs of `rockcraft-pack-action`

The rockcraft-pack-action provides an output rock (the filename of the rock produced). This is great for CI as reduces the boilerplate code needed to consume the output.

For the same reason, it would be great if this action also provided data like name, version, and probably others. This would make it really easy to chain a rockcraft-pack call with a skopeo copy, etc. A use can currently inspect the rockcraft.yaml file to get this information, but it feels more natural and convenient to be provided these directly from rockcraft-pack-action

[feature request] add support for packing rocks in multiple dirs

At the moment, the action automatically packs rocks in the root of the repository where the action is called or from path, assuming the Rockcraft project is there, but there are repositories, for instance pipelines-rocks, where the root of the repository does not contain a Rockcraft project, and there are instead, multiple of them inside different directories.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.