#github-actions (2023-12)

Discussions related to GitHub Actions

2023-12-01

samuel avatar

Hi every one, I have other question I need make a merge only to a commit especify, the option is only with comand checkout?

Dan Miller (Cloud Posse) avatar
Dan Miller (Cloud Posse)

you can checkout a specific commit like this https://devopscube.com/checkout-clone-specific-git-commit-id-sha/

How To Checkout/Clone From A Specific Git Commit Id (SHA)attachment image

There are scenarios where you might need to checkout or clone from a specific git commit id. This blog explains the steps involved in checking out a specific git commit ID (SHA).

2023-12-07

Insighttful avatar
Insighttful

Hi! From the cloudposse/github-action-pre-commit docs: By default, all hooks are run. Here’s a sample step configuration that only runs the flake8 hook against all the files (use the template above except for the pre-commit action):

    - uses: cloudposse/[email protected]
      with:
        extra_args: flake8 --all-files

How to run multiple hooks, BUT NOT a single hook OR all hooks? This fails:

- uses: cloudposse/[email protected]
      with:
        extra_args: black mypy isort flake8 --all-files
1
RB avatar

I don’t think it’s possible.

What might be better is to create a run step that runs your specific hook then find and run an action that pushes up changes.

RB avatar
jobs:
  precommit:
    steps:
      - use: actions/checkout@v4
      - run: |
          pre-commit run flake8
      # another action that pushes up changes if any changes exist
Insighttful avatar
Insighttful

Hi @RB and thank you for the feedback

RB avatar

np! if you find a better solution, please post here. this is just my personal perspective

2023-12-08

2023-12-14

actions Archives - The GitHub Blog avatar
actions Archives - The GitHub Blog
05:45:42 PM
GitHub Actions - Artifacts v4 is now Generally Available

GitHub Actions - Artifacts v4 is now Generally Available

The GitHub Blog - Updates, ideas, and inspiration from GitHub to help developers build and design software.

Updates, ideas, and inspiration from GitHub to help developers build and design software.

jose.amengual avatar
jose.amengual

I noticed this :

jose.amengual avatar
jose.amengual

the names do not match from the README

Dan Miller (Cloud Posse) avatar
Dan Miller (Cloud Posse)

thanks for pointing that out. We’re currently refactoring these repos (and READMEs) so we’ll add that to the list of items to fix

1
1
Erik Osterman (Cloud Posse) avatar
Erik Osterman (Cloud Posse)

@Gabriela Campana (Cloud Posse) task

1

2023-12-19

Erik Osterman (Cloud Posse) avatar
Erik Osterman (Cloud Posse)
#3168 Please rethink the "minimal image" idea for runner images

Currently the Runner Set runner image ships with no more packages than are necessary. This makes it extremely awkward to develop workflows (especially shared and Marketplace workflows) that run on both GitHub hosted runners and self-hosted runners, as you have to have the workflows install commands which are preinstalled on the GitHub hosted runners.

Obviously you want to slim the image down from the 20 GB of the GitHub hosted image to something that can be pulled all the time, and I’m not arguing for full feature parity, but please reconsider installing some extremely commonly used tools, such as

• git • curl • wget

It just seems insane on the face of it that we have to install git in an Official GitHub action runner image. Being able to retrieve files via curl and wget are so basic to bootstrapping anything else that the only argument I can see against including them is that they duplicate each other. Nevertheless, both are so popular (and small) that it seems needlessly dogmatic not to include them both.

I estimate that including just these 3 extra tools will cover 80% of the issues. I would prefer you also include jq, which, along with the other 3, would cover nearly all of my workflows, but I agree is not so basic.

The argument that we can build our own image neglects the fact that any marketplace or shared workflow that wants to be able to run on a self-hosted Runner Set must assume that only the tools on the official GitHub images are present. It also neglects the significant effort it takes to build, publish, and keep up-to-date a custom image.

2
jose.amengual avatar
jose.amengual

@Igor Rodionov I’m trying to implement a new pipeline with atmos and GitHub actions using this https://atmos.tools/integrations/github-actions/atmos-terraform-plan, and I just tried v2, and it does not work, the example does not have the right values

Atmos Terraform Plan | atmos

The Cloud Posse GitHub Action for “Atmos Terraform Plan” simplifies provisioning Terraform from within GitHub using workflows. Understand precisely what to expect from running a terraform plan from directly within the GitHub UI for any Pull Request.

jose.amengual avatar
jose.amengual

I have the bucket, dynamo, github provider and all that ready, I literally need to add the action and test a plan

Atmos Terraform Plan | atmos

The Cloud Posse GitHub Action for “Atmos Terraform Plan” simplifies provisioning Terraform from within GitHub using workflows. Understand precisely what to expect from running a terraform plan from directly within the GitHub UI for any Pull Request.

jose.amengual avatar
jose.amengual

mmm this does not work and the example is not correct

jose.amengual avatar
jose.amengual
cloudposse/github-action-atmos-affected-stacks

A composite workflow that runs the atmos describe affected command

jose.amengual avatar
jose.amengual

is missing has-affected-stacks: ${{ steps.affected.outputs.has-affected-stacks }}

jose.amengual avatar
jose.amengual

and the matrix I guess is now what it was the stacks before?

Igor Rodionov avatar
Igor Rodionov

@jose.amengual give a moment

jose.amengual avatar
jose.amengual

no problem, and thanks for jumping on this so quick

Igor Rodionov avatar
Igor Rodionov

Ok. It seem I know the problem

Igor Rodionov avatar
Igor Rodionov

could you pls try to add input nested-matrices-count: 1

Igor Rodionov avatar
Igor Rodionov

and try

Igor Rodionov avatar
Igor Rodionov

it seem I missed that in documentation

Igor Rodionov avatar
Igor Rodionov

if it will solve your problem, I will deeply describe what this input is about

jose.amengual avatar
jose.amengual

I did add that

jose.amengual avatar
jose.amengual

this is what I have :

name: Pull Request
on:
  pull_request:
    branches: [ 'main' ]
    types: [opened, synchronize, reopened, closed, labeled, unlabeled]

jobs:
  atmos-affected:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - id: affected
      uses: cloudposse/github-action-atmos-affected-stacks@v2
      with:
        atmos-gitops-config-path: ./.github/config/atmos-gitops.yaml
        nested-matrices-count: 1

    outputs:
        affected: ${{ steps.affected.outputs.affected }}
        matrix: ${{ steps.affected.outputs.matrix }}
        has-affected-stacks: ${{ steps.affected.outputs.has-affected-stacks }}

  atmos-plan:
    needs: ["atmos-affected"]
    if: ${{ needs.atmos-affected.outputs.has-affected-stacks }}
    name: ${{ matrix.stack_slug }}
    runs-on: ['self-hosted']
    strategy:
      max-parallel: 10
      fail-fast: false # Don't fail fast to avoid locking TF State
      matrix: ${{ fromJson(needs.atmos-affected.outputs.stacks) }}
    ## Avoid running the same stack in parallel mode (from different workflows)
    concurrency:
      group: ${{ matrix.stack_slug }}
      cancel-in-progress: false
    steps:
      - name: Plan Atmos Component
        uses: cloudposse/github-action-atmos-terraform-plan@v1
        with:
          component: ${{ matrix.component }}
          stack: ${{ matrix.stack }}
jose.amengual avatar
jose.amengual

but I think this is wrong too matrix: ${{ fromJson(needs.atmos-affected.outputs.stacks) }}

Igor Rodionov avatar
Igor Rodionov
if: ${{ needs.atmos-affected.outputs.has-affected-stacks == 'true' }}
Igor Rodionov avatar
Igor Rodionov

sure

Igor Rodionov avatar
Igor Rodionov

you right

Igor Rodionov avatar
Igor Rodionov

that’s typo

jose.amengual avatar
jose.amengual

so it should be ? fromJson(needs.atmos-affected.outputs.matrix?

Igor Rodionov avatar
Igor Rodionov

yes

jose.amengual avatar
jose.amengual

ok, testing…..

jose.amengual avatar
jose.amengual

now is doing something

jose.amengual avatar
jose.amengual

it created a bunch of jobs

1
jose.amengual avatar
jose.amengual

so far so good

Igor Rodionov avatar
Igor Rodionov

so, coming back to nested-matrices-count - if you will hit the problem 256 matrix limit for terraform plan GHA you can use it to extend the limit up to 65k with nested matrixes and reusable workflows workaround

Igor Rodionov avatar
Igor Rodionov

that’s what we have in this setting. But I’m not sure if we have example workflows for that pattern published yet

jose.amengual avatar
jose.amengual

my jobs are Waiting for a runner to pick up this job...

jose.amengual avatar
jose.amengual

crap….. I do not have self-hosted……

jose.amengual avatar
jose.amengual

changing….

jose.amengual avatar
jose.amengual

should be the run-on be github or matrix?

jose.amengual avatar
jose.amengual
 atmos-plan:
    needs: ["atmos-affected"]
    if: ${{ needs.atmos-affected.outputs.has-affected-stacks == 'true' }}
    name: ${{ matrix.stack_slug }}
    runs-on: ['github']
jose.amengual avatar
jose.amengual

I do not have self hosted runners

Igor Rodionov avatar
Igor Rodionov

‘ubuntu-latest’

jose.amengual avatar
jose.amengual

ohhhh

jose.amengual avatar
jose.amengual

ok now thay are running but no PRs created

jose.amengual avatar
jose.amengual

just checking in what is going on now

jose.amengual avatar
jose.amengual

I think the problem is here :

jq -rc --arg key settings.github.actions_enabled '. | getpath($key | split("."))' OUTPUT_FILE
jose.amengual avatar
jose.amengual

I do not have that setting

jose.amengual avatar
jose.amengual

is that something I can set globally?

jose.amengual avatar
jose.amengual

can you explain this ?

 terraform-state-role: arn:aws:iam::xxxxxxxxxxxx:role/cptest-core-ue2-auto-gitops-gha
  terraform-plan-role: arn:aws:iam::yyyyyyyyyyyy:role/cptest-core-gbl-identity-gitops
  terraform-apply-role: arn:aws:iam::yyyyyyyyyyyy:role/cptest-core-gbl-identity-gitops
jose.amengual avatar
jose.amengual

I have cptest-core-ue2-auto-gitops-gha role in my automation account

jose.amengual avatar
jose.amengual

and I have cptest-core-gbl-identity-gitops in the identity account

jose.amengual avatar
jose.amengual

which one is which?

jose.amengual avatar
jose.amengual

@marcelo.eguino

jose.amengual avatar
jose.amengual

@marcelo.eguino

Igor Rodionov avatar
Igor Rodionov

@jose.amengual sorry I was off.

Igor Rodionov avatar
Igor Rodionov

ok

Igor Rodionov avatar
Igor Rodionov
  1. Stacks that should be handled with github actions should have
    settings:
      github:
     actions_enabled: true
    
Igor Rodionov avatar
Igor Rodionov

example

Igor Rodionov avatar
Igor Rodionov
components:
  terraform:
    gha-tester:
      settings:
        github:
          actions_enabled: true
      metadata:
        component: s3-bucket
        inherits:
          - s3-bucket/defaults
      vars:
        #enabled: false
        name: gha-testing-2
        tags:
          foo: bar
Igor Rodionov avatar
Igor Rodionov

2

Igor Rodionov avatar
Igor Rodionov

This is roles provided by https://github.com/cloudposse/terraform-aws-components/tree/main/modules/gitops#outputs component that you have to install

Igor Rodionov avatar
Igor Rodionov

it would be used to store tf plan in separate s3 bucket

jose.amengual avatar
jose.amengual

I solved that issue now I’m getting

Assuming role with OIDC
Authenticated as assumedRoleId AROAWXCPEFSPJEZ4EJXCW:atmos-terraform-plan-gitops
Run set +e

Error: 
'atmos.yaml' CLI config files not found in any of the searched paths: system dir, home dir, current dir, ENV vars.
You can download a sample config and adapt it to your requirements from <https://raw.githubusercontent.com/cloudposse/atmos/master/examples/complete/atmos.yaml>

  with module.account_map.data.utils_component_config.config[0],
  on .terraform/modules/account_map/modules/remote-state/main.tf line 1, in data "utils_component_config" "config":
   1: data "utils_component_config" "config" {
jose.amengual avatar
jose.amengual

my atmos.yaml base_path: "."

jose.amengual avatar
jose.amengual

I’m trying to override the ATMOS_CLI_CONFIG ENV and I think the action is maybe not using the right dir?

jose.amengual avatar
jose.amengual

I see

    --output /home/runner/work/terraform-aws-infrastructure/terraform-aws-infrastructure/metadata/summary-pepe-ue1-nonprod-aws-config.md \
jose.amengual avatar
jose.amengual

is repeating the checkout dir

jose.amengual avatar
jose.amengual

before I the error I see ATMOS_CLI_CONFIG_PATH: /home/runner/work/terraform-aws-infrastructure/terraform-aws-infrastructure/atmos.yaml

jose.amengual avatar
jose.amengual

and my action config is atmos-config-path: atmos.yaml

jose.amengual avatar
jose.amengual

so maybe this part of the action is setting duplicating the path

jose.amengual avatar
jose.amengual
 # Set ATMOS_BASE_PATH allow `cloudposse/utils` provider to read atmos config from the correct path 
  ATMOS_BASE_PATH="./"
  echo "ATMOS_BASE_PATH=$(realpath ${ATMOS_BASE_PATH:-./})" >> $GITHUB_ENV
jose.amengual avatar
jose.amengual

@Igor Rodionov

jose.amengual avatar
jose.amengual

when you have some time , please let me know what the base_path should be and if I had to copy the atmos.yaml to some other directory

Igor Rodionov avatar
Igor Rodionov

This question better to address @Andriy Knysh (Cloud Posse)

2023-12-20

2023-12-21

    keyboard_arrow_up