-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
100 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,43 +2,88 @@ name: Test | |
|
||
on: [push] | ||
|
||
env: | ||
IMAGE_NAME: "nginx" | ||
IMAGE_TAG: "latest" | ||
REGISTRY_URL: "ghcr.io" | ||
REGISTRY_USERNAME: "${{ github.actor }}" | ||
REGISTRY_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | ||
APP_PORT: "80" | ||
PATH: "/" | ||
INITIAL_DELAY_SECONDS: "5" | ||
PERIOD_SECONDS: "10" | ||
|
||
jobs: | ||
linter: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v2 | ||
uses: actions/checkout@v4.1.1 | ||
|
||
- name: Lint YAML files | ||
uses: ibiqlik/[email protected] | ||
with: | ||
config_file: .yamllint.yml | ||
tester: | ||
|
||
test-remote-image: | ||
needs: linter | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/[email protected] | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/[email protected] | ||
|
||
- name: Build image and push to registry | ||
run: | | ||
docker buildx build \ | ||
--file ./test/Dockerfile \ | ||
--tag ghcr.io/arv1nt3/application:latest \ | ||
--push \ | ||
./test | ||
- name: Test Action with Sample Nginx Application | ||
uses: Arv1nt3/kubernetes-deployment-tester-action@main | ||
with: | ||
image_name: 'ghcr.io/arv1nt3/application:latest' | ||
use_local_image: false | ||
port: '5000' | ||
registry_token: ${{ secrets.GITHUB_TOKEN }} | ||
registry_url: ghcr.io | ||
registry_username: arv1nt3 | ||
command: 'flask' | ||
args: 'run,--host=0.0.0.0' | ||
env_vars: | | ||
- name: APP_KEY | ||
value: "YourAppKeyHere" | ||
- name: Remove Image from ghcr.io | ||
if: success() | ||
run: | | ||
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin | ||
docker rmi ghcr.io/arv1nt3/application:latest | ||
curl -X DELETE -u ${{ github.actor }}:${{ secrets.GITHUB_TOKEN }} \ | ||
"https://ghcr.io/v2/arv1nt3/application/manifests/latest" | ||
test-local-image: | ||
needs: linter | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v2 | ||
uses: actions/[email protected] | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/[email protected] | ||
|
||
- name: Build image and load locally | ||
run: | | ||
docker buildx build \ | ||
--file ./test/Dockerfile \ | ||
--tag ghcr.io/arv1nt3/application:latest \ | ||
--load \ | ||
./test | ||
- name: Test Action with Sample Nginx Application | ||
uses: Arv1nt3/kubernetes-deployment-tester-action@main | ||
with: | ||
image_name: '${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}' | ||
registry_url: ${{ env.REGISTRY_URL }} | ||
registry_username: ${{ env.REGISTRY_USERNAME }} | ||
registry_token: ${{ env.REGISTRY_TOKEN }} | ||
port: ${{ env.APP_PORT }} | ||
path: ${{ env.PATH }} | ||
initialDelaySeconds: ${{ env.INITIAL_DELAY_SECONDS }} | ||
periodSeconds: ${{ env.PERIOD_SECONDS }} | ||
image_name: 'ghcr.io/arv1nt3/application:latest' | ||
use_local_image: true | ||
port: '5000' | ||
registry_token: ${{ secrets.GITHUB_TOKEN }} | ||
registry_url: ghcr.io | ||
registry_username: arv1nt3 | ||
command: 'flask' | ||
args: 'run,--host=0.0.0.0' | ||
env_vars: | | ||
- name: APP_KEY | ||
value: "YourAppKeyHere" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Use a lightweight Python base image | ||
FROM python:3.9-slim | ||
|
||
# Install Flask | ||
RUN pip install Flask | ||
|
||
# Set the working directory | ||
WORKDIR /app | ||
|
||
# Copy the application script | ||
COPY app.py /app/app.py | ||
|
||
# The container listens on port 5000 by default | ||
EXPOSE 5000 | ||
|
||
# The application requires an environment variable APP_KEY to run | ||
# The application is started with 'flask run' command, which can be set through CMD | ||
CMD ["flask", "run", "--host=0.0.0.0"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from flask import Flask | ||
import os | ||
|
||
app = Flask(__name__) | ||
|
||
@app.route('/') | ||
def hello(): | ||
app_key = os.environ.get('APP_KEY') | ||
if not app_key: | ||
return "APP_KEY not set!", 500 | ||
return f"Hello, World! APP_KEY is {app_key}", 200 | ||
|
||
if __name__ == "__main__": | ||
app.run() |