DEV Community

Discussion on: Runtime Environment Variables with Github Actions

Collapse
 
ahmedateek profile image
Ahmed Ateek

with this code sample the action won't run due depreciation

The `set-env` command is disabled. Please upgrade to using Environment Files or opt into unsecure command execution by setting the `ACTIONS_ALLOW_UNSECURE_COMMANDS` environment variable to `true`. For more information see: https://github.blog/changelog/2020-10-01-github-actions-deprecating-set-env-and-add-path-commands/
Enter fullscreen mode Exit fullscreen mode

here is a fix for it if you don't mind to update the article,
thanks for the article.

      - name: "Set flag from Commit"
        id: step_one
        env:
          COMMIT_VAR: ${{ contains(github.event.head_commit.message, '[commit var]') }}
        run: |
          if ${COMMIT_VAR} == true; then
            echo "action_state=true" >> $GITHUB_ENV
            echo "flag set to true"
          else
            echo "action_state=false" >> $GITHUB_ENV
            echo "flag set to false"
          fi

      - name: "Use flag if true"
        if: env.action_state
        run: echo "${{ env.action_state }}" 
Enter fullscreen mode Exit fullscreen mode