mr-smithers-excellent / docker-build-push

Docker Build & Push GitHub Action
MIT License
281 stars 62 forks source link

Why is my organization's name a secret? #183

Closed guomaoqiu closed 11 months ago

guomaoqiu commented 12 months ago

Why is my organization's name a secret?

   outputs:
      image-name:
        description: URL for docker image
        value: ${{ jobs.build.outputs.image-name }}
      image-tag:
        description: image tag(version)
        value: ${{ jobs.build.outputs.image-tag }}
    secrets:
      GHCR_USERNAME:
        required: true
      GHCR_TOKEN:
        required: true
      GRAFANA_HOST:
        required: true
      GRAFANA_AUTH_TOKEN:
        required: true
      GRAFANA_FOLDER_NAME:
        required: true

jobs:        
  build:
    runs-on: ubuntu-latest
    environment: ${{ inputs.environment }}
    outputs:
      image-name: '${{ steps.docker_build.outputs.imageFullName }}'
      image-tag: '${{ steps.docker_build.outputs.tags }}'
    steps:
      - uses: actions/checkout@v4
      - uses: satackey/action-docker-layer-caching@v0.0.11
        # Ignore the failure of a step and avoid terminating the job.
        continue-on-error: true
      - name: Build and push
        id: docker_build
        uses: mr-smithers-excellent/docker-build-push@v6.2
        with:
          image: xxxxxxx
          registry: ghcr.io
          buildArgs: "GODWOKEN_CHAIN=${{ inputs.chain }},GWSCAN_GRAPHIQL=${{ inputs.graphiql }},GRAFANA_HOST=${{ secrets.GRAFANA_HOST }},GRAFANA_AUTH_TOKEN=${{ secrets.GRAFANA_AUTH_TOKEN }},GRAFANA_FOLDER_NAME=${{ secrets.GRAFANA_FOLDER_NAME }} "
          dockerfile: docker/Dockerfile
          username: ${{ secrets.GHCR_USERNAME }}
          password: ${{ secrets.GHCR_TOKEN }}
      - name: PrintImageFullNameInfo
        run: echo '${{ steps.docker_build.outputs.imageFullName }}:${{ steps.docker_build.outputs.tags }}'

In the final prompt, the github prompt contained a secret, but in fact it was just a string, which caused my subsequent work to be empty when obtaining the image-name. Eventually I was unable to update my image. image

image

mr-smithers-excellent commented 11 months ago

@guomaoqiu - can you try explicitly adding your githubOrg as a value for this action? If you don't provide it, the action uses @actions/github to retrieve it, which may result in the secret issue you're seeing. Example below:

uses: mr-smithers-excellent/docker-build-push@v6
with:
  image: image-name
  registry: ghcr.io
  githubOrg: override-org 
  username: ${{ secrets.GHCR_USERNAME }}
  password: ${{ secrets.GHCR_TOKEN }}