Skip to content

Instantly share code, notes, and snippets.

View guibranco's full-sized avatar
🎯
Focusing

Guilherme Branco Stracini guibranco

🎯
Focusing
View GitHub Profile
@guibranco
guibranco / sonarcloud.yml
Last active July 19, 2024 12:22
GitHub Actions workflow to build, test, and report to SonarCloud a .NET project.
name: SonarCloud Analysis
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
jobs:
@guibranco
guibranco / createIssueIfContentOfFileAndFileExistsViaPostman.js
Last active January 27, 2024 02:14
Create an issue to replace part of a file based on its content (and existence).
const ghToken = pm.globals.get("GH_PAT");
const authorizationHeader = `Authorization: Bearer ${ghToken}`;
const fileName = "appveyor.yml";
const pattern = "ps: $COVERLET_FORMATS = @('cobertura', 'lcov', 'opencover')";
const issueTitle = "Run all coverage formats at once per project";
const issueBody = "**Is your feature request related to a problem? Please describe.**\r\nRun all coverage formats at once per project\r\n\r\n**Describe the solution you'd like**\r\nReplace the actual code:\r\n```ps\r\n- ps: $TEST_PROJECTS = (Get-ChildItem -Path .\Tests\**\ -Recurse -Include *.csproj).Fullname\r\n- ps: $COVERLET_FORMATS = @('cobertura', 'lcov', 'opencover')\r\n- ps: |\r\n foreach($testProject in $TEST_PROJECTS)\r\n {\r\n foreach($coverletFormat in $COVERLET_FORMATS)\r\n {\r\n dotnet test $testProject /p:CollectCoverage=true /p:CoverletOutputFormat=\"$coverletFormat\"\r\n }\r\n }\r\n```\r\n\r\nWith the following code:\r\n```ps\r\n- ps: $TEST_PROJECTS = (Get-ChildItem -Path .\
@guibranco
guibranco / createIssueIfWorkflowExistsViaPostman.js
Created January 27, 2024 01:37
Create issue if a file exists in the repository (a specific workflow file).
const ghToken = pm.globals.get("GH_PAT");
const authorizationHeader = `Authorization: Bearer ${ghToken}`;
const workflowName = "build.yml"
const issueTitle = `Remove \`${workflowName}\``;
const repositories = pm.response.json();
for (let i = 0; i < repositories.length; i++) {
@guibranco
guibranco / Dockerfile
Created December 15, 2023 15:33
Docker file for PHP 8.3 with Apache, MySQLi extension, GD2 extension and Apache mod_rewrite enabled
FROM php:8.3-rc-apache
RUN apt-get update
RUN apt-get install --yes --force-yes cron g++ gettext libicu-dev openssl libc-client-dev libkrb5-dev libxml2-dev libfreetype6-dev libgd-dev libmcrypt-dev bzip2 libbz2-dev libtidy-dev libcurl4-openssl-dev libz-dev libmemcached-dev libxslt-dev
RUN a2enmod rewrite
RUN docker-php-ext-install mysqli
RUN docker-php-ext-enable mysqli
@guibranco
guibranco / generate_token.py
Created September 23, 2023 20:56
Generates a JWT for a GitHub application based on PEM file and APP ID.
#!/usr/bin/env python3
import jwt
import time
import sys
# Get PEM file path
if len(sys.argv) > 1:
pem = sys.argv[1]
else:
pem = input("Enter path of private PEM file: ")
@guibranco
guibranco / build-bump-version.yml
Last active September 17, 2023 20:25
A GitHub action to build (debug) .NET framework project with some comments/reports on the Pull Request
name: Build & Bump Version
on:
push:
branches:
- '*'
- '*/*'
- '**'
- '!main'
paths-ignore:
@guibranco
guibranco / generateHTMLfromJSON.js
Last active December 15, 2023 15:42
Generate HTML from repositories list from API response
const jsonData = pm.response.json();
const divPattern = "<div style=\"margin-top: 10px;\">";
const imageUrl = (item) => `https://github-readme-stats-guibranco.vercel.app/api/pin/?username=${item.organization.login}&amp;repo=${item.name}&amp;theme=dark&amp;bg_color=222222&amp;show_owner=true&amp;show_forks=false&amp;show_issues=true`;
const link = (item) => `<a href="${item.url}" target="_blank">${image(item)}</a>`;
const image = (item) => `<img style="min-height: 100px; padding-right: 10px;" src="${imageUrl(item)}" alt="${item.full_name}" />`;
var html = divPattern;
for(let i = 0; i < jsonData.length; i++){
html += link(jsonData[i]);
@guibranco
guibranco / clone.ps1
Last active August 2, 2023 16:36
Clone all repositories from an organization in Azure DevOps
$organization = "AZURE_DEVOPS_ORGANIZATION"
$personalAccessToken = "AZURE_DEVOPS_PAT"
$base64AuthInfo = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($personalAccessToken)"))
$headers = @{Authorization=("Basic {0}" -f $base64AuthInfo)}
Write-Host "Cloning all repositories from organization: " $organization
$projectsUrl = "https://dev.azure.com/" + [uri]::EscapeDataString($organization) + "/_apis/projects?api-version=7.0"
$result = Invoke-RestMethod -Uri $projectsUrl -Method Get -Headers $headers
@guibranco
guibranco / build-deploy.yml
Last active December 15, 2023 15:39
Sample CI GitHub Action file for .NET Framework (MSBuild)
name: CI
on:
push:
branches: [ main ]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
@guibranco
guibranco / build.yml
Last active December 15, 2023 15:40
Sample build & test GitHub Action file for .NET Framework (MSBuild)
name: Build
on:
push:
branches:
- '*'
- '*/*'
- '**'
- '!main'
paths-ignore: