question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Replace Hard-coded Paths with Already Existing Variable

See original GitHub issue

Problematic

At the end of the YAML for the continuous integration example, the upload-artifact step path uses a hard coded folder path:

https://github.com/microsoft/github-actions-for-desktop-apps/blob/d0fbf5cbc39057dea30244fb7ef6c5ae9c3b1ab8/.github/workflows/ci.yml#L93

Recommended

I believe this should be using the Wap_Project_Directory variable plus “AppPackages” subfolder instead.

Snippet

# Upload the MSIX package: https://github.com/marketplace/actions/upload-artifact
- name: Upload build artifacts
  uses: actions/upload-artifact@v1
  with:
    name: MSIX Package
    path: '$env:Wap_Project_Directory\AppPackages\'

[Edit] - Added the subfolder name to the variable. I’m not sure that’s how to concatenate the variable with a string in GitHub actions yet, but you get the point

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
lindexicommented, Mar 13, 2020

图片

1reaction
LanceMcCarthycommented, Mar 12, 2020

Since you already need the matrix variable for channel name, it wouldn’t be too much fluff to add another variable. However, the who point of a variable is that it’s value is different, so it defeats the purpose to have the same value in each matrix.

So instead, you could just add a comment where things are hard-coded. For example:

 # We need to use full path here because job variable is not in scope
 path: MyWpfApp.Package\AppPackages\ 

That way, developers who might clone/copy from this repo wont get hung up on a path that doesn’t exist in their app (you know folks are going to copy/paste without drilling deeper into each value).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can you use environment variables to replace hardcoded ...
I am probably going to use GAC for what I need to get done but I was wondering if using environment variables in...
Read more >
override hardcoded paths in executables
I'd like to override some hardcoded paths stored in pre-compiled executables like "/usr/share/nmap/" and redirect them to another dir. My ideal ...
Read more >
Using Path Variables in a DIM
A general advantage of using path variables instead of hard-coded paths is that if the source files are moved to a different directory...
Read more >
Hardcoded
Hard coded (not hardcorded) means that actual values that the user cannot change are used in the code rather than variables that can...
Read more >
Hard coding
Hard coding (also hard-coding or hardcoding) is the software development practice of embedding data directly into the source code of a program or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found