action-hexo icon indicating copy to clipboard operation
action-hexo copied to clipboard

Extra environment variables

Open oliversturm opened this issue 5 years ago • 2 comments

I'm trying to deploy Hexo to S3, for which two environment variables are required - in my workflow I have this:

      - name: Deploy
        uses: heowc/action-hexo@master
        env:
          AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
          AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
        with:
          args: deploy

According to the log, the S3 deployer can't find the environment variables, and looking at the docker command line it seems clear to me that these are not passed into the container. Not surprising, I guess... how could this work? Unless I'm missing something, the action doesn't currently support my scenario?

Perhaps it would be possible for the action to accept another parameter, so I could pass the names of my environment variables and then they could be passed on to the docker container?

oliversturm avatar Jan 15 '20 22:01 oliversturm

With a slightly better understanding of how GitHub workflows work, I have just managed to implement a solution - unfortunately it doesn't need your plugin at all! Since I'm doing npm install anyway, it crossed my mind that I could just use run to start the hexo ... commands - no docker required. And this works just fine and doesn't have any more environment variable problems.

I'm not sure how to proceed - to be blunt (no offence intended!), I'm not sure what benefit your action offers. Feel free to close this issue, although I believe it outlines an actual issue that others may encounter. For myself, I'm happy with the solution I found.

For completeness, here's the workflow I use now:

name: Deploy

on: push
jobs:
  build:
    name: Build
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
      - name: Setup Node 
        uses: actions/setup-node@v1
        with:
          node-version: '10.x'
      - name: NPM
        run: npm install
      - name: Clean
        run: ./node_modules/.bin/hexo clean
      - name: Generate
        run: ./node_modules/.bin/hexo generate
      - name: Deploy
        run: ./node_modules/.bin/hexo deploy
        env:
          AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
          AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

oliversturm avatar Jan 15 '20 22:01 oliversturm

Good idea!

heowc avatar Jan 24 '20 11:01 heowc