From the course: Practical GitHub Actions

Testing your actions - GitHub Tutorial

From the course: Practical GitHub Actions

Testing your actions

- [Instructor] All right, so now that I have this action finished, you'll notice that it's telling me that I can publish this action to the Marketplace. That's because it's realized that I have all the files necessary to do that, but I'm not going to do that yet because I need to write a better description, which I'll do later. But then, I also need to make sure that I test this before I just publish it to the Marketplace. No sense to publish it if it's not working. So I'm going to go back to my podcast-test and modify this action so that I can use the other repo, the podcast generator repo, to process the files. So I'm going to go into Actions. You'll see that there's some workflows that are running and failing. That's because these are the ones for the different branches that I created. No big deal. We're going to be replacing the workflow here with our new workflow. So we're going to go to this Generate Podcast Feeds and then we are going to click on any one of these dots and go to the workflow file. That's going to show us the workflow for this run. And then, we're going to hit the Edit button. That, basically, has taken us to podcast-test, to .github file workflows and the main.yml file. You could also just go to the repo and then just, literally, just open the main.yml file from here. But I wanted to show you a different way of doing it. Now, I'm going to hit the Edit button and you're going to see that this is a much simpler process. It's still going to Generate Podcast Feeds on push and most of the top is going to remain the same but I'm not going to do any of the things that I'm already doing in the other action. So I'm going to delete everything here. I'm still going to use the Checkout Repo action, but then I'm going to add another step here and I'll call this one Run Feed Generator. And here, I'm going to say, uses. And here, I need to type in my username. So you'd be typing your username. And then, you type in the name of the repo that you want to run. So our repo is called podcast-generator, so we'll type that in here, podcast-generator. And normally, what we would do here is specify a release from the Marketplace, like we're doing right here. We're saying use the version three of this checkout action, But here, we can just refer to a repository and then include a branch that we want to run on. So until we create a release, we can run any other sort of test action, like podcast-generator, by using this nomenclature. Notice that it's a lot easier from now on to create these. So let's go ahead and commit these changes. We'll hit Commit Changes, and now it should be trying to use the podcast-generator action. We will see what's happening in here, in Actions. We'll see the pages build and deployment happen and Update YAML also happen. All right, so I knew that this error was going to happen. So let me show you what's going on. I'll click on Update YAML to take a look at the process that it went through and I'll click on build. And you could see that it failed when it was trying to run the Feed Generator step. And once again, you can open this up to see what it tells you. And I'm not really fond of the errors that it tells you because it says, error response from daemon: failed to create shim task, et cetera, et cetera. Now, the key thing here is that, is this right here. It says that the entrypoint.sh: permission denied: unknown. In the list of errors that took me forever to figure out, this probably wins one of the greatest awards ever. This error means that the entrypoint.sh file doesn't have right permissions to it. Now, it is really difficult to find out where this is, but I'm just going to fix it, because. We can do it by going back into our Codespace. You could already have it running and then issuing a command to make sure that this entrypoint has the right permissions. So let's try that. All right, so now that we're here, we can go ahead and pull up a terminal and we're going to issue a command called, chmod -R 775. And then, we'll say entrypoint.sh. And that will change the permissions. I can issue an ls -la command, and I can take a look at the permissions for entrypoint.sh and see that it has the right permissions, so it needs to be able to execute, basically. Now that we have that, then let's try a git status. It looked like it knows that it modified entrypoint.sh, so I'll add this, commit it, and then, I'll go ahead and push it. All right, that's going to push everything back onto the server, hopefully with the right permissions. And now, I can try rerunning this again. I think I could easily just modify one of the files again and it would also work, but we'll just try rerunning it. The suspense is killing me, so I'm actually going to see it as it runs, and you can see that it's going through all the different steps. If you don't really need to read all of this right here, from this step, you can collapse it. The one that we are concerned about is this Checkout Repo step. So we'll wait for it, see if it fails. All right, this time it looks like everything ran without errors, so that is progress. Now, let's go back to Actions and see if it shows it. Yeah, it looks like it shows it. Well, it says seven minutes ago, so I don't know that it ran it properly. Let's just go ahead and modify the podcast feed.yaml to make a change. Just a silly change like before, we're just going to add a dash here to just force this thing to rerun and hopefully it'll work just fine. All right, so we'll go back into Actions. We'll take a look at our process run. All right, so it looks like everything built properly. Let's go into the Code and we should be able to see our updated feed, and let's just make sure that it has that dash that we added. And there it is. So that's actually a fantastic way of being able to use a separate project that you can update for multiple podcasts and handle your podcast empire with a single action.

Contents