Coder Social home page Coder Social logo

idpbesties-dotnet-gha's Introduction

Scaffold Action

Slack

This GitHub action allows you to quickly scaffold repositories using any selected Cookiecutter Template via Port Actions.

In addition, as cookiecutter is an Open Source project you can make your own project, learn more about it here

Inputs

Input Description Required Default
token The GitHub Token to use to authenticate with the API with permissions to create repositories within the organization make sure to use Fine-grained token Yes
portClientId The Port Client ID to use to authenticate with the API Yes
portClientSecret The Port Client Secret to use to authenticate with the API Yes
blueprintIdentifier The blueprint identifier to use to populate the Port Yes Service
repositoryName The name of the repository to create Yes
organizationName The name of the organization to create the repository in Yes
cookiecutterTemplate The cookiecutter template to use to populate the repository Yes
portUserInputs Port user inputs to came from triggering the action Yes
portRunId Port run ID to came from triggering the action Yes
monorepoUrl If using scaffolding within a monorepo specify the URL here Yes
scaffoldDirectory Root folder to scaffold when using monorepo Yes
githubURL GitHub url for self hosted version Yes https://api.github.com
createPortEntity Whether should create port entity with the action or not. You can set this to false if you'd like to create the entry yourself with port-labs/port-github-action No true

Quickstart - Scaffold Golang Template

Follow these steps to get started with the Golang template

  1. Create the following GitHub action secrets
  • ORG_TOKEN - a PAT (Personal Access Token) with permissions to create repositories
  • PORT_CLIENT_ID - Port Client ID learn more
  • PORT_CLIENT_SECRET - Port Client Secret learn more
  1. Install the Ports GitHub app from here.
  2. Create a blueprint at Port with the following properties:

Note Keep in mind this can be any blueprint you would like and this is just an example

{
  "identifier": "microservice",
  "title": "Microservice",
  "icon": "Microservice",
  "schema": {
    "properties": {
      "description": {
        "title": "Description",
        "type": "string"
      },
      "url": {
        "title": "URL",
        "format": "url",
        "type": "string"
      },
      "readme": {
        "title": "README",
        "type": "string",
        "format": "markdown",
        "icon": "Book"
      }
    },
    "required": []
  },
  "mirrorProperties": {},
  "calculationProperties": {},
  "relations": {}
}
  1. Create an action at Port with the following JSON file:

Note Keep in mind that any field started with cookiecutter will automtically be injected into the cookiecutter inputs as a variable here for example we are using the cookiecutter_app_name input of the Golang Template

[
  {
    "identifier": "scaffold",
    "title": "Scaffold Golang Microservice",
    "icon": "Git",
    "userInputs": {
      "properties": {
        "name": {
          "title": "Repo Name",
          "type": "string"
        },
        "cookiecutter_app_name": {
          "type": "string",
          "title": "Application Name"
        }
      },
      "required": [
        "name"
      ]
    },
    "invocationMethod": {
      "type": "GITHUB",
      "org": "port-cookiecutter-example",
      "repo": "gha-templater",
      "workflow": "scaffold-golang.yml",
      "omitUserInputs": true
    },
    "trigger": "CREATE",
    "description": "Scaffolding a new Microservice from a set of templates using Cookiecutter"
  }
]
  1. Create a workflow file under .github/workflows/scaffold-golang.yml with the following content:
on:
  workflow_dispatch:
    inputs:
      port_payload:
        required: true
        description: "Port's payload, including details for who triggered the action and general context (blueprint, run id, etc...)"
        type: string
    secrets: 
      ORG_TOKEN: 
        required: true
      PORT_CLIENT_ID:
        required: true
      PORT_CLIENT_SECRET:
        required: true
jobs: 
  scaffold:
    runs-on: ubuntu-latest
    steps:
      - uses: port-labs/[email protected]
        with:
          portClientId: ${{ secrets.PORT_CLIENT_ID }}
          portClientSecret: ${{ secrets.PORT_CLIENT_SECRET }}
          token: ${{ secrets.ORG_TOKEN }}
          portRunId: ${{ fromJson(inputs.port_payload).context.runId }}
          repositoryName: ${{ fromJson(inputs.port_payload).payload.properties.name }}
          portUserInputs: ${{ toJson(fromJson(inputs.port_payload).payload.properties) }} 
          cookiecutterTemplate: https://github.com/lacion/cookiecutter-golang
          blueprintIdentifier: 'microservice'
          organizationName: INSERT_ORG_NAME
  1. Trigger the action from Port UI. gif

Monorepo

If you would like to create a PR in a monorepo subfolder instead, you can fill out the following inputs

  monorepoUrl: <your-monorepo-url>
  scaffoldDirectory: <directory to scaffold in i.e apps/> 

Connecting Port's GitHub exporter

To make sure all of the properties (like url, readme etc..) come directly from Github in a seamless way, you can connect our GitHub exporter next here you can find more information about it.

idpbesties-dotnet-gha's People

Contributors

danielsinai avatar gcaya avatar matanheledport avatar omrigez avatar hadar-co avatar nedyalkov avatar starcraft66 avatar yonabogu avatar

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.