From the course: Practical GitHub Actions
Creating an entry point - GitHub Tutorial
From the course: Practical GitHub Actions
Creating an entry point
- [Instructor] All right, let's take care of building this entry point file that the Docker file is going to call upon. So I'm going to hit the plus sign here to create a new file, and I'll type in entrypoint.sh. So this is pretty much a file that will run as if you are running terminal commands, but all the commands are going to be in a file. So we're going to start with the shebang. This basically specifies the interpreter that's going to execute this script, so we'll say bin/bash, we're using Bash here, and we'll issue an echo statement. So here, whenever you use an echo statement, it just basically prints something out to the command line. This is useful if you want to debug some things, and when the action runs, this will print out as well. So it's a great place for you to put in little messages. I like to put these sort of dashes, so that when this action runs, I can actually see this section in the sort of long list of commands that are scrolling by as I see the action run. So here now we're going to do things that we've done in other places. So I'll do a git config and set the user. I don't want to do the mail. I'll do the username first, and in here, I'm going to add the GITHUB_ACTOR. So this is going to allow me to sort of keep track of who is running the action. That way, if different people are using this action that I'm building, it's going to say that person's username as opposed to just a generic one. It's a little bit better. So we'll do the same thing for email, and this one's called INPUT_EMAIL. And then we'll do one more to make sure that we can run workflows, and this will be global add safe directory and github/workspace. This will just make sure that we are adding this to the safe list of directories so that we can run git operations in here. So next up, we'll go ahead and execute Python. Because we installed Python 3, we have to say Python 3 here. And then we will run usr/bin/feed.py, because that's where we copied it to in our Docker file. So remember, we copied, like, this feed.py to usr/bin.py, so we're just referring to that. Then I'm going to just issue a git add minus A, I could do a period if I wanted to, and then just like I would in the terminal, I can also just issue a commit. I could do these in separate lines, but why do that? Update feed. All right, it looks like GitHub Copilot. It's really helpful, but it keeps on turning itself on, so I'll just disable it for Shell Script as well. Although we're almost done here, so we do a git add, git commit, and then we'll do a git push, and we'll have to do the set upstream. We don't normally have to do this, but again, this is sort of like a new machine, so we just make sure that the upstream branch is set up. I think a lot of times I assume that these things are going to be done, but when you're kind of working with a clean machine, you have to do a lot of the stuff that you don't normally have to do. So upstream origin main. So basically, this is allowing us to use Git, run our Python, and then also send things back to the server. So whatever Python file generates, which will be at our podcast.xml, is going to push that back upstream to the main branch. Right? So that should be it for the entry point, and now we have one more file that we need to generate. We'll continue that in the next video.