Closed aginaugustine closed 2 years ago
It seems as though your file is located here:
``
and it should be located here:
.github/actions/cat-facts/src/main.py
Solution
Click here to edit main.py
and move it to the proper directory
requirements.txt
with your Python dependenciesπ‘All of the following steps take place inside of the .github/actions/cat-facts
directory.
A requirements.txt
file is required so that the Python package manger, PIP, knows which dependancies to install when our Docker image get's built. In our case we will only need to add the requests
package to our requirements.txt
Create and add the following contents to the .github/actions/cat-facts/requirements.txt
file:
You can use this link to easily create this file.
requests
Commit the changes to this branch.
πLearn PIP
I'll respond when you push changes to this pull request.
Dockerfile
Awesome π
This action now has three of the four key files it needs to run:
Dockerfile
for the cat-fat actionLastly we will create the Dockerfile
, just like we did with our first action.
Create and add the following contents to the .github/actions/cat-facts/Dockerfile
file:
You can use this link to easily create this file.
FROM python:3
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
CMD [ "python", "/src/main.py" ]
Commit the changes to this branch
Click the green Commit new file
button
I'll respond when you push changes to this pull request.
At this point we can't expect much from our workflow, if you remember all of its contents are commented out. Let's go ahead and fix that now so that we can see our action fetch us a cat fact.
We are going to add a new trigger to our workflow to make it easier for us to trigger it without the need to push changes to the repository. Remember that every time our workflow runs this action we should see a new cat fact which means we need a good way to make it run a few times. If you recall there are many events that trigger a workflow run.
We will use the pull_request
event and specify the activity type to be when an issue get's labeled
. This will allow us to trigger our workflow by simply placing a label on this pull request.
Let's change the tigger and add the cat fact action
Edit your current workflow file. It should have the following contents:
name: Docker Actions
on:
pull_request:
types: [labeled]
jobs:
action:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: hello-action
uses: ./.github/actions/hello-world
- name: meow
uses: ./.github/actions/cat-facts
Commit the changes to this branch
I'll respond when you push changes to this pull request.
Great job! Everything is all set up and now we are ready to start learning about cats π. You will find you have some cat fact related labels available to you in this repository. You don't have to use them, any label will trigger our workflow, but it might be easier to follow along with me if you use the labels I suggest.
first-cat-fact
label to this pull requestsecond-cat-fact
label to this pull requestFeel free to continue adding labels to this pull request if you want to see more facts.
When you are ready to move forward in the lesson merge this pull request into the main
branch. I will respond when you've merged this pull request.
test