Skip to content

Instantly share code, notes, and snippets.

View lpsm-dev's full-sized avatar
🌊
Trying to... what?

Lucca lpsm-dev

🌊
Trying to... what?
View GitHub Profile
@lpsm-dev
lpsm-dev / README.md
Created June 6, 2024 04:08
[GitHub Actions] - Components of GitHub Actions

The components of GitHub Actions

image

There are several components that work together to run tasks or jobs within a GitHub Actions workflow. In short, an event triggers the workflow, which contains a job. This job then uses steps to dictate which actions will run within the workflow. To better see how these components work together, let's take a quick look at each one.

Workflows

A workflow is an automated process that you add to your repository. A workflow needs to have at least one job, and different events can trigger it. You can use it to build, test, package, release, or deploy your repository's project on GitHub.

@lpsm-dev
lpsm-dev / README.md
Created June 6, 2024 03:35
[GitHub Actions] - Describe best practices for creating actions

It's essential to follow best practices when creating actions:

  • Create chainable actions. Don't create large monolithic actions. Instead, create smaller functional actions that can be chained together.
  • Version your actions like other code. Others might take dependencies on various versions of your actions. Allow them to specify versions.
  • Provide the latest label. If others are happy to use the latest version of your action, make sure you provide the latest label that they can specify to get it.
  • Add appropriate documentation. As with other codes, documentation helps others use your actions and can help avoid surprises about how they function.
  • Add details action.yml metadata. At the root of your action, you'll have an action.yml file. Ensure it has been populated with author, icon, expected inputs, and outputs.
  • Consider contributing to the marketplace. It's easier for us to work with actions when we all contribute to the marketplace. Help to avoid people needing to relearn the same issues endlessly.
@lpsm-dev
lpsm-dev / main.tf
Created January 6, 2024 20:41
[IaC] - Dynamic create TFCloud workspaces
resource "tfe_workspace" "this" {
for_each = local.tfc_workspaces
name = "${local.tfc_project}-${each.key}"
organization = data.tfe_organization.this.name
project_id = tfe_project.this.id
auto_apply = false
force_delete = true
global_remote_state = true
trigger_patterns = try(each.value.custom_trigger_patterns, ["./${each.key}/*"])
@lpsm-dev
lpsm-dev / main.ps1
Created June 5, 2023 14:26
[DevOps] - Azure DevOps pipeline Release Classic Check
$headers = @{ Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN" }
$orgName = $env:ORG_NAME
$projectName = $env:SYSTEM_TEAMPROJECT
$releaseRefId = $env:RELEASE_REF_ID
$releaseRefStageName = $env:RELEASE_REF_STAGE_NAME
Write-Host "======================================================="
$releasRefURL = "https://vsrm.dev.azure.com/$orgName/$projectName/_apis/release/releases?definitionId=$releaseRefId&api-version=5.1"
Write-Host "=> Release Ref URL: [$releasRefURL]"
@lpsm-dev
lpsm-dev / README.md
Created April 20, 2023 14:18
Update sonarqube 8.5 - 8.9 admin password
kubectl exec -it <pod-name> -- sh
psql -h localhost -p 5432 -U sonarUser sonarDB
select * from users;
@lpsm-dev
lpsm-dev / main.sh
Created March 17, 2023 17:19
[DevOps] - Script to setup a quality gate in Sonarqube project
#!/bin/bash
# Define variables
SONARQUBE_TOKEN=""
SONARQUBE_URL=""
QUALITY_GATE_NAME=""
PROJECT_KEY=""
# Get quality gate ID
QUALITY_GATE_ID=$(curl -s -u $SONARQUBE_TOKEN: -X GET "$SONARQUBE_URL/api/qualitygates/list" | jq -r '.qualitygates[] | select(.name=="'"$QUALITY_GATE_NAME"'") | .id')
@lpsm-dev
lpsm-dev / main.rb
Created October 6, 2022 20:02
[GitLab] - Create Admin user in Rails Console
user = User.new(username: 'user', email: 'user@user.com.br', name: 'user', password: 'user', password_confirmation: 'user')
# Use it only if you wish user to be automatically confirmed. If skipped, user receives confirmation e-mail
user.skip_confirmation!
user.admin = true
user.save!
@lpsm-dev
lpsm-dev / main.sh
Created June 30, 2022 17:09
[General] - Convert file .cer to .pem using OpenSSL command
openssl x509 -in production-services-us-east-1.cer -outform pem -out production-services-us-east-1.pem
@lpsm-dev
lpsm-dev / main.sh
Last active February 4, 2024 17:52
[K8S] - Delete terminating namespace
# General
kubectl patch RESOURCE NAME -p '{"metadata":{"finalizers":[]}}' --type=merge
# Ingress
kubectl delete -A ValidatingWebhookConfiguration ingress-nginx-admission
kubectl patch ns ingress-nginx -p '{"metadata":{"finalizers":[]}}' --type=merge
kubectl patch ingress forwarding-ingress-nginx -n ingress-nginx -p '{"metadata":{"finalizers":[]}}' --type=merge
kubectl patch services ingress-nginx-production-controller -n ingress-nginx -p '{"metadata":{"finalizers":[]}}' --type=merge
# PVC
@lpsm-dev
lpsm-dev / policy.json
Created May 30, 2022 16:56
[AWS] - KMS Policy usage
{
"Sid": "Allow use of the key",
"Action": [
"kms:Decrypt",
"kms:GenerateDataKey"
],
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::111122223333:user/Jane"
},