Skip to content

Conversation

@hknutsen
Copy link
Member

@hknutsen hknutsen commented Nov 14, 2025

There could be multiple jobs in a workflow deploying to the same environment, so using the environment name as a unique identifier could fail in some scenarios.

Generate a unique artifact name based on job and run ID instead - there can only be one job of a given ID within a workflow run of a given ID, i.e. the combination of the two will be unique.

For example, consider the following workflow .github/workflows/deploy-infra.yml:

name: Deploy infrastructure

on:
  push:
    branches: [main]
    paths: [terraform/**]

permissions: {}

jobs:
  deploy-dev:
    name: Deploy dev
    permissions:
      contents: read
      id-token: write
    uses: equinor/ops-actions/.github/workflows/[email protected]
    with:
      environment: dev
      terraform_version: 1.13.5
      working_directory: terraform
    secrets:
      AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
      AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
      AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
      ENCRYPTION_PASSWORD: ${{ secrets.ENCRYPTION_PASSWORD }}

Imagine that you push a change to the main branch, triggering a workflow run that gets a unique ID 12842626712. The artifact would get the name terraform-deploy-dev-12842626712, which is unique within that workflow run.

There could be multiple jobs in a workflow deploying to the same environment, so using the environment name as a unique identifier could fail in some scenarios.

Generate a unique artifact name based on job and run ID instead - there can only be one job of a given ID within a workflow run of a given ID, i.e. the combination of the two will be unique.
@hknutsen hknutsen marked this pull request as ready for review November 14, 2025 10:31
@hknutsen hknutsen requested a review from a team as a code owner November 14, 2025 10:31
@hknutsen
Copy link
Member Author

github.job might need to be set at step-level rather than workflow- or job-level. Will test then mark as ready for review again.

@hknutsen hknutsen marked this pull request as draft November 14, 2025 11:56
@hknutsen
Copy link
Member Author

[...] The artifact would get the name terraform-deploy-dev-12842626712, which is unique within that workflow run.

Currently artifact name is terraform-terraform-plan-12842626712, which is not what I want 🫠

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