├── .gitignore ├── cleanup ├── index.js ├── action.yml ├── package.json └── cleanup.js ├── renovate.json ├── s3-upload ├── package.json ├── action.yml └── index.js ├── clang-format └── action.yml ├── changed-files └── action.yml ├── close-snap └── action.yml ├── check └── action.yml └── .github └── workflows └── test_changed_files.yaml /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | -------------------------------------------------------------------------------- /cleanup/index.js: -------------------------------------------------------------------------------- 1 | console.log('Scheduling cleanup in post'); 2 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json", 3 | "extends": [ 4 | "config:recommended" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /cleanup/action.yml: -------------------------------------------------------------------------------- 1 | name: 'Cleanup' 2 | description: 'Cleans up the runner after build finishes' 3 | author: 'Saviq' 4 | branding: 5 | icon: 'delete' 6 | color: 'red' 7 | inputs: 8 | paths: 9 | description: 'Paths to clean up' 10 | required: true 11 | runs: 12 | using: 'node12' 13 | main: 'index.js' 14 | post: 'cleanup.js' 15 | -------------------------------------------------------------------------------- /s3-upload/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "s3-upload", 3 | "version": "0.0.1", 4 | "main": "index.js", 5 | "author": "Michał Sawicz ", 6 | "license": "MIT", 7 | "dependencies": { 8 | "@actions/core": "1", 9 | "aws-sdk": "^2.730.0" 10 | }, 11 | "repository": { 12 | "type": "git", 13 | "url": "https://github.com/canonical/actions.git" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /cleanup/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cleanup", 3 | "version": "0.0.1", 4 | "main": "index.js", 5 | "author": "Michał Sawicz ", 6 | "license": "MIT", 7 | "dependencies": { 8 | "@actions/core": "1", 9 | "@actions/glob": "0", 10 | "@actions/io": "1" 11 | }, 12 | "repository": { 13 | "type": "git", 14 | "url": "https://github.com/canonical/actions.git" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /cleanup/cleanup.js: -------------------------------------------------------------------------------- 1 | const core = require('@actions/core'); 2 | const glob = require('@actions/glob'); 3 | const io = require('@actions/io'); 4 | 5 | async function main() { 6 | const globber = await glob.create(core.getInput('paths'), {implicitDescendants: false}); 7 | 8 | try { 9 | const paths = await globber.glob(); 10 | for (const path of paths) { 11 | console.log(`Deleting ${path}`); 12 | await io.rmRF(path); 13 | } 14 | } catch (error) { 15 | core.setFailed(error.message); 16 | } 17 | } 18 | 19 | main().catch(err => console.log(`Failed to delete files: ${err}`)); 20 | -------------------------------------------------------------------------------- /s3-upload/action.yml: -------------------------------------------------------------------------------- 1 | name: 'S3 Upload' 2 | description: 'Upload file to S3' 3 | author: 'Saviq' 4 | branding: 5 | icon: 'upload-cloud' 6 | color: 'green' 7 | inputs: 8 | path: 9 | description: 'Path to the file to upload' 10 | required: true 11 | bucket: 12 | description: 'Bucket to upload to' 13 | required: true 14 | prefix: 15 | description: 'Prefix to upload to' 16 | required: false 17 | default: '' 18 | public: 19 | description: 'Whether to make the file public (default: false)' 20 | required: false 21 | default: false 22 | storage-class: 23 | description: 'Which storage class to use (default: STANDARD_IA)' 24 | required: false 25 | default: 'STANDARD_IA' 26 | outputs: 27 | url: 28 | description: 'URL of the uploaded file' 29 | runs: 30 | using: 'node12' 31 | main: 'index.js' 32 | -------------------------------------------------------------------------------- /clang-format/action.yml: -------------------------------------------------------------------------------- 1 | name: Clang-Format 2 | description: Run `clang-format` on the diff 3 | 4 | inputs: 5 | version: 6 | description: "The version of clang-format to use, defaults to 10" 7 | required: true 8 | default: 10 9 | reference: 10 | description: "The ref the diff against which to check, defaults to HEAD^1" 11 | required: true 12 | # On pull requests, HEAD^1 will always be the merge base, so consider that diff for formatting. 13 | default: HEAD^1 14 | 15 | runs: 16 | using: composite 17 | 18 | steps: 19 | - name: Install clang-format 20 | shell: bash 21 | run: sudo apt-get install --no-install-recommends --yes clang-format-${{ inputs.version }} 22 | 23 | - name: Run clang-format through the diff 24 | shell: bash 25 | run: | 26 | set -euo pipefail 27 | 28 | git diff -U0 --no-color ${{ inputs.reference }} | clang-format-diff-${{ inputs.version }} -p1 | tee ${HOME}/clang-diff 29 | if [ "$( stat --printf='%s' ${HOME}/clang-diff )" -ne 0 ]; then 30 | echo "##[error] Please apply the above diff to correct formatting" 31 | exit 1 32 | fi 33 | -------------------------------------------------------------------------------- /changed-files/action.yml: -------------------------------------------------------------------------------- 1 | name: Changed files 2 | description: Get list of changed files between two git refs. 3 | 4 | inputs: 5 | base-ref: 6 | description: Base branch (destination of a pull request). Defaults to the base branch of the pull request. 7 | required: false 8 | default: ${{ github.base_ref }} 9 | head-ref: 10 | description: Head branch (source of a pull request). Defaults to the ref of the pull request. 11 | required: false 12 | default: ${{ github.ref }} 13 | 14 | outputs: 15 | changed-files: 16 | description: List of changed files 17 | value: ${{ steps.changed-files.outputs.all_changed_files }} 18 | 19 | runs: 20 | using: composite 21 | steps: 22 | - name: Get changed files 23 | id: changed-files 24 | shell: bash 25 | run: | 26 | git fetch origin ${{ inputs.base-ref }}:refs/heads/changed_base --depth 1 27 | git fetch origin ${{ inputs.head-ref }}:refs/heads/changed_head --depth 1 28 | 29 | cat <> $GITHUB_OUTPUT 30 | all_changed_files< core.error(`Failed to upload file: ${err}`)); 50 | -------------------------------------------------------------------------------- /check/action.yml: -------------------------------------------------------------------------------- 1 | name: Check 2 | description: Create or update a check on the given repository 3 | 4 | inputs: 5 | app_id: 6 | description: The application ID 7 | required: true 8 | private_key: 9 | description: The application private key 10 | required: true 11 | repo: 12 | description: The repository to create/update the check on 13 | required: true 14 | sha: 15 | description: The commit SHA to create/update the check on 16 | required: true 17 | name: 18 | description: The name of the check 19 | required: false 20 | check_id: 21 | description: The ID of the check to update 22 | required: false 23 | status: 24 | description: The check status 25 | required: false 26 | default: completed 27 | conclusion: 28 | description: The check's conclusion 29 | required: false 30 | details_url: 31 | description: The URL to link back 32 | required: false 33 | output: 34 | description: The check details 35 | required: false 36 | 37 | outputs: 38 | check_id: 39 | description: The ID of the created/updated check 40 | value: ${{ steps.check.outputs.check_id }} 41 | 42 | runs: 43 | using: composite 44 | 45 | steps: 46 | - name: Create an App token 47 | id: app-token 48 | uses: tibdex/github-app-token@v1 49 | with: 50 | app_id: ${{ inputs.app_id }} 51 | private_key: ${{ inputs.private_key }} 52 | repository: ${{ inputs.repo }} 53 | 54 | - name: Create a check on public 55 | id: check 56 | uses: LouisBrunner/checks-action@v1.1.1 57 | with: 58 | token: ${{ steps.app-token.outputs.token }} 59 | repo: ${{ inputs.repo }} 60 | sha: ${{ inputs.sha }} 61 | name: ${{ inputs.name }} 62 | check_id: ${{ inputs.check_id }} 63 | status: ${{ inputs.status }} 64 | conclusion: ${{ inputs.conclusion }} 65 | details_url: ${{ inputs.details_url }} 66 | output: ${{ inputs.output }} 67 | -------------------------------------------------------------------------------- /.github/workflows/test_changed_files.yaml: -------------------------------------------------------------------------------- 1 | name: Test changed-files action 2 | 3 | on: 4 | pull_request: 5 | paths: 6 | - 'changed-files/action.yml' 7 | 8 | jobs: 9 | test-changed-file: 10 | name: Check that changed-files action detects changed files in the current PR 11 | runs-on: ubuntu-latest 12 | steps: 13 | - name: Checkout repository 14 | uses: actions/checkout@v4 15 | with: 16 | fetch-depth: 1 17 | 18 | - name: Get changed files 19 | id: changed-files 20 | uses: ./changed-files 21 | 22 | - name: Check changed files output 23 | run: | 24 | changed_files="${{ steps.changed-files.outputs.changed-files }}" 25 | # This action only triggers on changes to `changed-files/action.yml` 26 | # Thus `changed-files/action.yml` should be in the list of changed files 27 | expected_file="changed-files/action.yml" 28 | 29 | # Check that the file is in the list of changed files 30 | if echo $changed_files | grep --fixed-strings --quiet --line-regexp "$expected_file"; then 31 | echo "$expected_file found in changed files" 32 | else 33 | echo "$expected_file not found in changed files" 34 | exit 1 35 | fi 36 | 37 | test-known-refs: 38 | name: Check that changed-files action works with custom refs 39 | runs-on: ubuntu-latest 40 | steps: 41 | - name: Checkout repository 42 | uses: actions/checkout@v4 43 | with: 44 | fetch-depth: 1 45 | 46 | - name: Get changed files 47 | id: changed-files 48 | uses: ./changed-files 49 | with: 50 | base-ref: a7fc56f262863f374b44aa020e163c013d3c75ad 51 | head-ref: 20063fbd0a3dde28a87d0a8767a4f16c7a5c9c6e 52 | 53 | - name: Check changed files output 54 | run: | 55 | changed_files="${{ steps.changed-files.outputs.changed-files }}" 56 | # We know that `changed-files/action.yml` is changed between the two refs 57 | expected_file="changed-files/action.yml" 58 | 59 | # Check that the file is in the list of changed files 60 | if echo $changed_files | grep --fixed-strings --quiet --line-regexp "$expected_file"; then 61 | echo "$expected_file found in changed files" 62 | else 63 | echo "$expected_file not found in changed files" 64 | exit 1 65 | fi 66 | 67 | test-unchanged-file: 68 | name: Check that changed-files action does not detect unchanged files 69 | runs-on: ubuntu-latest 70 | steps: 71 | - name: Checkout repository 72 | uses: actions/checkout@v4 73 | with: 74 | fetch-depth: 1 75 | 76 | - name: Get changed files 77 | id: changed-files 78 | uses: ./changed-files 79 | with: 80 | base-ref: a7fc56f262863f374b44aa020e163c013d3c75ad 81 | head-ref: 20063fbd0a3dde28a87d0a8767a4f16c7a5c9c6e 82 | 83 | - name: Check changed files output 84 | run: | 85 | changed_files="${{ steps.changed-files.outputs.changed-files }}" 86 | # We know that `renovate.json` is not changed between the two refs 87 | expected_file="renovate.json" 88 | 89 | # Check that the file is *not* in the list of changed files 90 | if echo $changed_files | grep --fixed-strings --quiet --line-regexp "$expected_file"; then 91 | echo "$expected_file found in changed files" 92 | exit 1 93 | else 94 | echo "$expected_file not found in changed files" 95 | fi 96 | 97 | --------------------------------------------------------------------------------