Skip to content

Instantly share code, notes, and snippets.

@MPTG94
Last active May 5, 2023 17:12
Show Gist options
  • Select an option

  • Save MPTG94/2592fa43acd816eef06c37b0db907166 to your computer and use it in GitHub Desktop.

Select an option

Save MPTG94/2592fa43acd816eef06c37b0db907166 to your computer and use it in GitHub Desktop.
Modified GitHub workflow SDLC template
name: Report SDLC to Port
on:
workflow_call:
workflow_dispatch:
push:
branches:
- master
- main
jobs:
report-to-port:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
persist-credentials: true
fetch-depth: 2
- name: Extract SHA short
if: ${{ always() }}
id: get-short-sha
run: |
echo "SHA_SHORT=${GITHUB_SHA:0:7}" >> $GITHUB_OUTPUT
- name: "Readme content"
id: readme
run: |
echo "readme=$(awk '{printf("%s\n", $0)}' README.md | tr '\n' '|' | sed 's/|/\\n/g')" >> "$GITHUB_OUTPUT"
- name: "Report service to port"
if: ${{ always() }}
uses: port-labs/port-github-action@v1
with:
clientId: ${{ secrets.PORT_CLIENT_ID }}
clientSecret: ${{ secrets.PORT_CLIENT_SECRET }}
identifier: ${{ github.event.repository.name }}
title: ${{ github.event.repository.name }}
blueprint: service
properties: |
{
"name": "${{ github.event.repository.name }}",
"url": "${{ github.server_url }}/${{ github.repository }}",
"README": "${{ steps.readme.outputs.readme }}",
"about": "${{ github.event.repository.description }}"
}
- name: "Report deployment to Port 🚢"
if: ${{ always() }}
uses: port-labs/port-github-action@v1
with:
clientId: ${{ secrets.PORT_CLIENT_ID }}
clientSecret: ${{ secrets.PORT_CLIENT_SECRET }}
identifier: ${{ steps.get-short-sha.outputs.SHA_SHORT }}
title: ${{ steps.get-short-sha.outputs.SHA_SHORT }}
blueprint: deployment
properties: |
{
"triggeringActor": "${{ github.actor }}",
"link": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}",
"commitSha": "${{ github.sha }}",
"status": "success",
"deployBranchUrl": "${{ github.server_url }}/${{ github.repository }}/tree/${{ github.ref_name }}",
"deployBranch": "${{ github.ref_name }}"
}
relations: |
{
"service": "${{ github.event.repository.name }}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment