How to Deploy Python hello-world.app using GITHUB ACTION WORKFLOW
Step 1: Create a New Repository
-
Create a new repository on GitHub by clicking the "+" button and selecting "New repository."
-
Name your repository (e.g., "Python-hello-world.app").
-
Choose any other repository settings you prefer, and create the repository.
Step 2: Create the Python Script
-
In your new repository, click on the "Add file" button and choose "Create new file."
-
Name the file
hello.py
. -
Add the following Python code to the
hello.py
file:
print("Hello, World!")
- Commit the changes by adding a commit message and clicking "Commit new file."
Step 3: Create a GitHub Actions Workflow
-
In your repository, click on the "Actions" tab.
-
Choose "Set up a workflow yourself."
-
Replace the content in the text editor with the following YAML code:
name: Hello World Python App
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.x
- name: Run Python script
run: python hello.py
- Click on "Start commit" to commit the workflow file to your repository.
Step 4: Trigger the Workflow
-
In your repository, click on the "Actions" tab again.
-
You'll see your workflow listed. Click on "Hello World Python App."
-
On the right side, click on the "Run workflow" button. Select "Run workflow" to manually trigger the workflow.
-
You should see your workflow running. Click on the build job to see the logs.
-
Once the workflow completes, you should see the "Hello, World!" message in the logs.
Output of build file will be something like below.