Skip to content

fix: adjust mfe-deploy workflow environment parameters#7

Merged
Ang-m4 merged 3 commits intomainfrom
afg/fix-reusable-actions
Mar 13, 2025
Merged

fix: adjust mfe-deploy workflow environment parameters#7
Ang-m4 merged 3 commits intomainfrom
afg/fix-reusable-actions

Conversation

@Ang-m4
Copy link
Collaborator

@Ang-m4 Ang-m4 commented Mar 12, 2025

Problem

In GitHub Actions, vars and secrets are evaluated based on the environment specified when calling a job using the environment: key. However, according to GitHub's official documentation, reusable workflows do not currently support defining environments at initialization. Reference.

Changes

To address this limitation, the reusable workflow must access vars and secrets directly, as inputs from the caller workflow will not be populated due to the missing environment.

Updates:

  • Removed all input fields.
  • Accessed secrets and vars directly from the job instead of relying on caller inputs.

@Ang-m4 Ang-m4 force-pushed the afg/fix-reusable-actions branch from e2eaf14 to f11bbce Compare March 12, 2025 19:59
Copy link

@johanseto johanseto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I liked the inputs option...

Anyway I think we could make like a list in readme or comment inline this action explaining how the vars would be configurated by env or general. Also secrets.
Because this was an explicit form to do it but is removed xD

      NODE_VERSION:
        description: The Node.js version to use
        required: true
        type: string
      ATLAS_OPTIONS:
        description: Options for pulling translations (if needed)
        required: false
        type: string
        default: ""
      PUBLIC_PATH_CDN:
        description: The public CDN path for deployment
        required: true
        type: string
      APP_ID:
        description: Application ID used for naming and identification
        required: true
        type: string
      MFE_CONFIG_API_URL:
        description: Configuration API URL for the MFE
        required: true
        type: string
      BUCKET_NAME:
        description: S3 bucket name (without s3:// prefix)
        required: true
        type: string
  1. I was thinking and I would ask if you could share how do you call the action...
    You need secrets inherit in the caller?

@Ang-m4
Copy link
Collaborator Author

Ang-m4 commented Mar 13, 2025

@johanseto, I really liked the previous version that included input definitions! It’s unfortunate that in reusable workflows, the caller cannot set the environment before execution.

This is how the reusable workflow is being called. Secrets are passed as inherit because I wasn’t sure if explicitly declaring the secrets in the caller without the environment would work. This way, when the job sets the environment, the correct secrets are used:

name: MFE S3 Bucket Deployment 🚀

on:
  push:
    branches:
      - open-release/redwood.nelp
      - open-rc/redwood.nelp

  pull_request:
    branches:
       - "**open-rc**"

jobs:
  deployment:
    uses: nelc/actions-hub/.github/workflows/mfe-s3-bucket-deployment.yml@main
    with:
     PROD_BRANCH: 'open-release/redwood.nelp'
    secrets: inherit

@Ang-m4
Copy link
Collaborator Author

Ang-m4 commented Mar 13, 2025

About the variables description, maybe some comments about the github variables and secrets might work.

# MFE S3 Bucket Deployment Workflow

# PURPOSE:
#   This workflow builds and deploys a Micro Frontend (MFE) application to an AWS S3 bucket

# TRIGGER:
#   This is a reusable workflow that can be called from other workflows using workflow_call.
#
# INPUTS:
#   - PROD_BRANCH: Name of the production branch (required) - used to determine environment

# REQUIRED GITHUB VARIABLES (vars):
#   - NODE_VERSION: Version of Node.js to use for building
#   - APP_ID: The ID/name of the MFE application
#   - PUBLIC_PATH_CDN: The CDN URL where the MFE will be hosted
#   - MFE_CONFIG_API_URL: The API URL for the MFE configuration
#   - BUCKET_NAME: The name of the S3 bucket where the MFE will be deployed
#   - ATLAS_OPTIONS: Optional. Configuration for translation pulling (if empty, step is skipped)

# REQUIRED SECRETS:
#   - AWS_ACCESS_KEY_ID: AWS access key ID with permissions to deploy to S3
#   - AWS_SECRET_ACCESS_KEY: AWS secret access key
#   - AWS_DEFAULT_REGION: AWS region where the S3 bucket is located
#   - AWS_CLOUDFRONT_DISTRIBUTION_ID: CloudFront distribution ID for cache invalidation

what do you think?

@johanseto
Copy link

johanseto commented Mar 13, 2025

About the variables description, maybe some comments about the github variables and secrets might work.

# MFE S3 Bucket Deployment Workflow

# PURPOSE:
#   This workflow builds and deploys a Micro Frontend (MFE) application to an AWS S3 bucket

# TRIGGER:
#   This is a reusable workflow that can be called from other workflows using workflow_call.
#
# INPUTS:
#   - PROD_BRANCH: Name of the production branch (required) - used to determine environment

# REQUIRED GITHUB VARIABLES (vars):
#   - NODE_VERSION: Version of Node.js to use for building
#   - APP_ID: The ID/name of the MFE application
#   - PUBLIC_PATH_CDN: The CDN URL where the MFE will be hosted
#   - MFE_CONFIG_API_URL: The API URL for the MFE configuration
#   - BUCKET_NAME: The name of the S3 bucket where the MFE will be deployed
#   - ATLAS_OPTIONS: Optional. Configuration for translation pulling (if empty, step is skipped)

# REQUIRED SECRETS:
#   - AWS_ACCESS_KEY_ID: AWS access key ID with permissions to deploy to S3
#   - AWS_SECRET_ACCESS_KEY: AWS secret access key
#   - AWS_DEFAULT_REGION: AWS region where the S3 bucket is located
#   - AWS_CLOUDFRONT_DISTRIBUTION_ID: CloudFront distribution ID for cache invalidation

what do you think?

I like it if possible could you add like a flag for variables that depends on environment.
eg:
- PUBLIC_PATH_CDN: The CDN URL where the MFE will be hosted **(env_based)**

@Ang-m4 Ang-m4 requested a review from johanseto March 13, 2025 19:08
@Ang-m4
Copy link
Collaborator Author

Ang-m4 commented Mar 13, 2025

@johanseto, I just updated the comments as you suggested!

Copy link

@johanseto johanseto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A little doctstring improvement. But lets go to test how integrates

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also env based. I think so

@Ang-m4 Ang-m4 force-pushed the afg/fix-reusable-actions branch from 3a19d42 to b6cae0b Compare March 13, 2025 19:33
@Ang-m4 Ang-m4 force-pushed the afg/fix-reusable-actions branch from b6cae0b to ebd6d7c Compare March 13, 2025 19:34
@Ang-m4 Ang-m4 merged commit a2dd32a into main Mar 13, 2025
2 checks passed
@Ang-m4 Ang-m4 deleted the afg/fix-reusable-actions branch March 13, 2025 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments