19 changed files with 258 additions and 515 deletions
@ -1,6 +1,9 @@
@@ -1,6 +1,9 @@
|
||||
from flask import Flask |
||||
|
||||
app = Flask(__name__) |
||||
|
||||
from app import views # noqa: E402,F401 |
||||
from app import apis # noqa: E402,F401 |
||||
def create_app(): |
||||
app = Flask(__name__) |
||||
with app.app_context(): |
||||
from . import views # noqa: E402,F401 |
||||
from . import apis # noqa: E402,F401 |
||||
return app |
||||
|
@ -0,0 +1,10 @@
@@ -0,0 +1,10 @@
|
||||
from . import create_app |
||||
import pytest |
||||
|
||||
app = create_app() |
||||
|
||||
|
||||
@pytest.fixture |
||||
def client(): |
||||
with app.test_client() as client: |
||||
yield client |
@ -0,0 +1,27 @@
@@ -0,0 +1,27 @@
|
||||
import json |
||||
|
||||
|
||||
def test_api_process(client): |
||||
resp = client.get("/api/process") |
||||
|
||||
assert resp.status_code == 200 |
||||
assert resp.headers["Content-Type"] == "application/json" |
||||
resp_payload = json.loads(resp.data) |
||||
assert len(resp_payload["processes"]) > 0 |
||||
assert resp_payload["processes"][0]["memory_percent"] > 0 |
||||
assert len(resp_payload["processes"][0]["name"]) > 0 |
||||
|
||||
|
||||
def test_api_monitor(client): |
||||
resp = client.get("/api/monitor") |
||||
|
||||
assert resp.status_code == 200 |
||||
assert resp.headers["Content-Type"] == "application/json" |
||||
resp_payload = json.loads(resp.data) |
||||
assert resp_payload["cpu"] >= 0 |
||||
assert resp_payload["disk"] >= 0 |
||||
assert resp_payload["disk_read"] >= 0 |
||||
assert resp_payload["disk_write"] >= 0 |
||||
assert resp_payload["mem"] >= 0 |
||||
assert resp_payload["net_recv"] >= 0 |
||||
assert resp_payload["net_sent"] >= 0 |
@ -0,0 +1,22 @@
@@ -0,0 +1,22 @@
|
||||
import pprint |
||||
|
||||
|
||||
def test_home(client): |
||||
resp = client.get("/") |
||||
|
||||
assert resp.status_code == 200 |
||||
assert b"Python" in resp.data |
||||
|
||||
|
||||
def test_page_content(client): |
||||
resp = client.get("/") |
||||
|
||||
assert resp.status_code == 200 |
||||
assert b"Coleman" in resp.data |
||||
|
||||
|
||||
def test_info(client): |
||||
resp = client.get("/info") |
||||
|
||||
assert resp.status_code == 200 |
||||
assert b"Hostname" in resp.data |
@ -1,157 +1,140 @@
@@ -1,157 +1,140 @@
|
||||
{ |
||||
"info": { |
||||
"_postman_id": "d758a295-d6e7-40ac-a6ba-d9312cf9bbe5", |
||||
"name": "Python Demoapp", |
||||
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" |
||||
}, |
||||
"item": [ |
||||
{ |
||||
"name": "Check Home Page", |
||||
"event": [ |
||||
{ |
||||
"listen": "test", |
||||
"script": { |
||||
"exec": [ |
||||
"pm.test(\"Home Page: Successful GET request\", function () {", |
||||
" pm.response.to.be.ok;", |
||||
"});", |
||||
"", |
||||
"pm.test(\"Home Page: Response valid & HTML body\", function () {", |
||||
" pm.response.to.be.withBody;", |
||||
" pm.expect(pm.response.headers.get('Content-Type')).to.contain('text/html');", |
||||
"});", |
||||
"", |
||||
"pm.test(\"Home Page: Check content\", function () {", |
||||
" pm.expect(pm.response.text()).to.include('Python');", |
||||
"});", |
||||
"" |
||||
], |
||||
"type": "text/javascript" |
||||
} |
||||
} |
||||
], |
||||
"request": { |
||||
"method": "GET", |
||||
"header": [], |
||||
"url": { |
||||
"raw": "http://{{apphost}}/", |
||||
"protocol": "http", |
||||
"host": [ |
||||
"{{apphost}}" |
||||
], |
||||
"path": [ |
||||
"" |
||||
] |
||||
} |
||||
}, |
||||
"response": [] |
||||
}, |
||||
{ |
||||
"name": "Check Info Page", |
||||
"event": [ |
||||
{ |
||||
"listen": "test", |
||||
"script": { |
||||
"exec": [ |
||||
"pm.test(\"Info Page: Successful GET request\", function () {", |
||||
" pm.response.to.be.ok;", |
||||
"});", |
||||
"", |
||||
"pm.test(\"Info Page: Response valid & HTML body\", function () {", |
||||
" pm.response.to.be.withBody;", |
||||
" pm.expect(pm.response.headers.get('Content-Type')).to.contain('text/html');", |
||||
"});", |
||||
"", |
||||
"pm.test(\"Info Page: Check content\", function () {", |
||||
" pm.expect(pm.response.text()).to.include('Network Interfaces');", |
||||
"});", |
||||
"" |
||||
], |
||||
"type": "text/javascript" |
||||
} |
||||
} |
||||
], |
||||
"request": { |
||||
"method": "GET", |
||||
"header": [], |
||||
"url": { |
||||
"raw": "http://{{apphost}}/info", |
||||
"protocol": "http", |
||||
"host": [ |
||||
"{{apphost}}" |
||||
], |
||||
"path": [ |
||||
"info" |
||||
] |
||||
} |
||||
}, |
||||
"response": [] |
||||
}, |
||||
{ |
||||
"name": "Check Process API", |
||||
"event": [ |
||||
{ |
||||
"listen": "test", |
||||
"script": { |
||||
"exec": [ |
||||
"pm.test(\"Process API: Successful GET request\", function () {", |
||||
" pm.response.to.be.ok;", |
||||
"});", |
||||
"", |
||||
"pm.test(\"Process API: Response valid & JSON body\", function () {", |
||||
" pm.response.to.be.withBody;", |
||||
" pm.response.to.be.json;", |
||||
"});", |
||||
"", |
||||
"pm.test(\"Process API: Check API response\", function () {", |
||||
" var processData = pm.response.json();", |
||||
" pm.expect(processData.processes).to.be.an('array')", |
||||
" pm.expect(processData.processes[0].name).to.be.an('string')", |
||||
" pm.expect(processData.processes[0].memory_percent).to.be.an('number')", |
||||
" pm.expect(processData.processes[0].pid).to.be.an('number')", |
||||
"});", |
||||
"" |
||||
], |
||||
"type": "text/javascript" |
||||
} |
||||
} |
||||
], |
||||
"request": { |
||||
"method": "GET", |
||||
"header": [], |
||||
"url": { |
||||
"raw": "https://{{apphost}}/api/process", |
||||
"protocol": "https", |
||||
"host": [ |
||||
"{{apphost}}" |
||||
], |
||||
"path": [ |
||||
"api", |
||||
"process" |
||||
] |
||||
} |
||||
}, |
||||
"response": [] |
||||
} |
||||
], |
||||
"event": [ |
||||
{ |
||||
"listen": "prerequest", |
||||
"script": { |
||||
"type": "text/javascript", |
||||
"exec": [ |
||||
"" |
||||
] |
||||
} |
||||
}, |
||||
{ |
||||
"listen": "test", |
||||
"script": { |
||||
"type": "text/javascript", |
||||
"exec": [ |
||||
"" |
||||
] |
||||
} |
||||
} |
||||
] |
||||
} |
||||
"info": { |
||||
"_postman_id": "d758a295-d6e7-40ac-a6ba-d9312cf9bbe5", |
||||
"name": "Python Demoapp", |
||||
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" |
||||
}, |
||||
"item": [ |
||||
{ |
||||
"name": "Check Home Page", |
||||
"event": [ |
||||
{ |
||||
"listen": "test", |
||||
"script": { |
||||
"exec": [ |
||||
"pm.test(\"Home Page: Successful GET request\", function () {", |
||||
" pm.response.to.be.ok;", |
||||
"});", |
||||
"", |
||||
"pm.test(\"Home Page: Response valid & HTML body\", function () {", |
||||
" pm.response.to.be.withBody;", |
||||
" pm.expect(pm.response.headers.get('Content-Type')).to.contain('text/html');", |
||||
"});", |
||||
"", |
||||
"pm.test(\"Home Page: Check content\", function () {", |
||||
" pm.expect(pm.response.text()).to.include('Python');", |
||||
"});", |
||||
"" |
||||
], |
||||
"type": "text/javascript" |
||||
} |
||||
} |
||||
], |
||||
"request": { |
||||
"method": "GET", |
||||
"header": [], |
||||
"url": { |
||||
"raw": "http://{{apphost}}/", |
||||
"protocol": "http", |
||||
"host": ["{{apphost}}"], |
||||
"path": [""] |
||||
} |
||||
}, |
||||
"response": [] |
||||
}, |
||||
{ |
||||
"name": "Check Info Page", |
||||
"event": [ |
||||
{ |
||||
"listen": "test", |
||||
"script": { |
||||
"exec": [ |
||||
"pm.test(\"Info Page: Successful GET request\", function () {", |
||||
" pm.response.to.be.ok;", |
||||
"});", |
||||
"", |
||||
"pm.test(\"Info Page: Response valid & HTML body\", function () {", |
||||
" pm.response.to.be.withBody;", |
||||
" pm.expect(pm.response.headers.get('Content-Type')).to.contain('text/html');", |
||||
"});", |
||||
"", |
||||
"pm.test(\"Info Page: Check content\", function () {", |
||||
" pm.expect(pm.response.text()).to.include('Network Interfaces');", |
||||
"});", |
||||
"" |
||||
], |
||||
"type": "text/javascript" |
||||
} |
||||
} |
||||
], |
||||
"request": { |
||||
"method": "GET", |
||||
"header": [], |
||||
"url": { |
||||
"raw": "http://{{apphost}}/info", |
||||
"protocol": "http", |
||||
"host": ["{{apphost}}"], |
||||
"path": ["info"] |
||||
} |
||||
}, |
||||
"response": [] |
||||
}, |
||||
{ |
||||
"name": "Check Process API", |
||||
"event": [ |
||||
{ |
||||
"listen": "test", |
||||
"script": { |
||||
"exec": [ |
||||
"pm.test(\"Process API: Successful GET request\", function () {", |
||||
" pm.response.to.be.ok;", |
||||
"});", |
||||
"", |
||||
"pm.test(\"Process API: Response valid & JSON body\", function () {", |
||||
" pm.response.to.be.withBody;", |
||||
" pm.response.to.be.json;", |
||||
"});", |
||||
"", |
||||
"pm.test(\"Process API: Check API response\", function () {", |
||||
" var processData = pm.response.json();", |
||||
" pm.expect(processData.processes).to.be.an('array')", |
||||
" pm.expect(processData.processes[0].name).to.be.an('string')", |
||||
" pm.expect(processData.processes[0].memory_percent).to.be.an('number')", |
||||
" pm.expect(processData.processes[0].pid).to.be.an('number')", |
||||
"});", |
||||
"" |
||||
], |
||||
"type": "text/javascript" |
||||
} |
||||
} |
||||
], |
||||
"request": { |
||||
"method": "GET", |
||||
"header": [], |
||||
"url": { |
||||
"raw": "http://{{apphost}}/api/process", |
||||
"protocol": "http", |
||||
"host": ["{{apphost}}"], |
||||
"path": ["api", "process"] |
||||
} |
||||
}, |
||||
"response": [] |
||||
} |
||||
], |
||||
"event": [ |
||||
{ |
||||
"listen": "prerequest", |
||||
"script": { |
||||
"type": "text/javascript", |
||||
"exec": [""] |
||||
} |
||||
}, |
||||
{ |
||||
"listen": "test", |
||||
"script": { |
||||
"type": "text/javascript", |
||||
"exec": [""] |
||||
} |
||||
} |
||||
] |
||||
} |
||||
|
@ -1,107 +0,0 @@
@@ -1,107 +0,0 @@
|
||||
# |
||||
# Deploy to Azure Kubernetes Service using Helm |
||||
# Using Bicep for infrastructure as code |
||||
# |
||||
|
||||
name: CD Release - AKS |
||||
|
||||
on: |
||||
workflow_dispatch: |
||||
inputs: |
||||
IMAGE_TAG: |
||||
description: "Image tag to be deployed" |
||||
required: true |
||||
default: "latest" |
||||
|
||||
# Note. Required secrets: CR_PAT & AZURE_CREDENTIALS |
||||
|
||||
env: |
||||
AKS_NAME: benc |
||||
AKS_RES_GROUP: aks |
||||
HELM_RELEASE: python |
||||
HELM_NAMESPACE: demoapps |
||||
INGRESS_DNS_HOST: python-demoapp.kube.benco.io |
||||
|
||||
jobs: |
||||
# |
||||
# Deploy to Kubernetes (AKS) |
||||
# |
||||
deploy-aks: |
||||
name: Deploy to AKS with Helm |
||||
runs-on: ubuntu-latest |
||||
outputs: |
||||
deployment_id: ${{ steps.deploy.outputs.deployment_id }} |
||||
|
||||
steps: |
||||
- name: "Checkout" |
||||
uses: actions/checkout@v1 |
||||
|
||||
- name: "Start deployment" |
||||
id: deploy |
||||
uses: chrnorm/deployment-action@v1.2.0 |
||||
with: |
||||
ref: ${{ github.event.ref }} |
||||
token: ${{ github.token }} |
||||
environment: AKS - ${{ env.HELM_RELEASE }} |
||||
|
||||
- name: "Login to Azure" |
||||
uses: azure/login@v1 |
||||
with: |
||||
creds: ${{ secrets.AZURE_CREDENTIALS }} |
||||
|
||||
- name: "Get AKS credentials" |
||||
run: | |
||||
az aks get-credentials -n $AKS_NAME -g $AKS_RES_GROUP |
||||
|
||||
- name: "Helm release" |
||||
run: | |
||||
helm repo add benc-uk https://benc-uk.github.io/helm-charts |
||||
helm upgrade ${{ env.HELM_RELEASE }} benc-uk/webapp \ |
||||
--install \ |
||||
--namespace ${{ env.HELM_NAMESPACE }} \ |
||||
--values ./kubernetes/aks-live.yaml \ |
||||
--set image.tag=${{ github.event.inputs.IMAGE_TAG }},ingress.host=${{ env.INGRESS_DNS_HOST }} |
||||
|
||||
- name: "End deployment - failure" |
||||
if: ${{ failure() }} |
||||
uses: chrnorm/deployment-status@v1.0.0 |
||||
with: |
||||
token: ${{ github.token }} |
||||
state: failure |
||||
deployment_id: ${{ needs.deploy-bicep.outputs.deployment_id }} |
||||
|
||||
# |
||||
# Post deployment testing stage |
||||
# |
||||
validate-deployment: |
||||
name: "Run Deployment Tests" |
||||
needs: deploy-aks |
||||
runs-on: ubuntu-latest |
||||
steps: |
||||
- name: "Checkout" |
||||
uses: actions/checkout@v2 |
||||
|
||||
- name: "Validate site is running" |
||||
run: .github/scripts/url-check.sh -u https://${{ env.INGRESS_DNS_HOST }} -s "Python" -t 200 |
||||
|
||||
# - name: "Run API tests" |
||||
# run: | |
||||
# npm install newman --silent |
||||
# node_modules/newman/bin/newman.js run src/tests/postman_collection.json --global-var apphost=${{ env.INGRESS_DNS_HOST }} |
||||
|
||||
- name: "End deployment - success" |
||||
if: ${{ success() }} |
||||
uses: chrnorm/deployment-status@v1.0.0 |
||||
with: |
||||
token: ${{ github.token }} |
||||
state: success |
||||
deployment_id: ${{ needs.deploy-aks.outputs.deployment_id }} |
||||
environment_url: https://${{ env.INGRESS_DNS_HOST }} |
||||
|
||||
- name: "End deployment - failure" |
||||
if: ${{ failure() }} |
||||
uses: chrnorm/deployment-status@v1.0.0 |
||||
with: |
||||
token: ${{ github.token }} |
||||
state: failure |
||||
deployment_id: ${{ needs.deploy-aks.outputs.deployment_id }} |
@ -1,114 +0,0 @@
@@ -1,114 +0,0 @@
|
||||
# |
||||
# Deploy to Azure App Service as a containerized Web App |
||||
# Using Bicep for infrastructure as code |
||||
# |
||||
|
||||
name: CD Release - Webapp |
||||
|
||||
on: |
||||
workflow_dispatch: |
||||
inputs: |
||||
IMAGE_TAG: |
||||
description: "Image tag to be deployed" |
||||
required: true |
||||
default: "latest" |
||||
|
||||
# Note. Required secrets: CR_PAT & AZURE_CREDENTIALS |
||||
|
||||
env: |
||||
IMAGE_REG: ghcr.io |
||||
IMAGE_REPO: benc-uk/python-demoapp |
||||
APP_NAME: python-demoapp |
||||
ARM_SUB_ID: 52512f28-c6ed-403e-9569-82a9fb9fec91 |
||||
ARM_REGION: westeurope |
||||
ARM_RES_GROUP: apps |
||||
|
||||
jobs: |
||||
# |
||||
# Deploy Azure infra (App Service) using Bicep |
||||
# |
||||
deploy-infra: |
||||
name: "Deploy Infra" |
||||
runs-on: ubuntu-latest |
||||
outputs: |
||||
deployment_id: ${{ steps.deploy.outputs.deployment_id }} |
||||
|
||||
steps: |
||||
- name: "Checkout" |
||||
uses: actions/checkout@v2 |
||||
|
||||
- name: "Start deployment" |
||||
id: deploy |
||||
uses: chrnorm/deployment-action@v1.2.0 |
||||
with: |
||||
ref: ${{ github.event.ref }} |
||||
token: ${{ github.token }} |
||||
environment: App Service - ${{ env.APP_NAME }} |
||||
|
||||
- name: "Run Bicep compiler" |
||||
run: | |
||||
wget https://github.com/Azure/bicep/releases/download/v0.1.37-alpha/bicep-linux-x64 -qO bicep |
||||
chmod +x bicep |
||||
./bicep build webapp.bicep |
||||
working-directory: ./infra |
||||
|
||||
- name: "Login to Azure" |
||||
uses: azure/login@v1 |
||||
with: |
||||
creds: ${{ secrets.AZURE_CREDENTIALS }} |
||||
|
||||
- name: "Create resource group" |
||||
run: az group create --name ${{ env.ARM_RES_GROUP }} --location ${{ env.ARM_REGION }} |
||||
|
||||
- name: "Deploy resources" |
||||
uses: azure/arm-deploy@v1 |
||||
with: |
||||
subscriptionId: ${{ env.ARM_SUB_ID }} |
||||
resourceGroupName: ${{ env.ARM_RES_GROUP }} |
||||
template: ./infra/webapp.json |
||||
parameters: webappName=${{ env.APP_NAME }} webappImage=${{ env.IMAGE_REG }}/${{ env.IMAGE_REPO }}:${{ github.event.inputs.IMAGE_TAG }} weatherKey=${{ secrets.WEATHER_API_KEY }} |
||||
deploymentName: webapp-deploy-${{ github.run_id }} |
||||
|
||||
- name: "End deployment - failure" |
||||
if: ${{ failure() }} |
||||
uses: chrnorm/deployment-status@v1.0.0 |
||||
with: |
||||
token: ${{ github.token }} |
||||
state: failure |
||||
deployment_id: ${{ needs.deploy-bicep.outputs.deployment_id }} |
||||
|
||||
# |
||||
# Post deployment testing stage |
||||
# |
||||
validate-deployment: |
||||
name: "Run Deployment Tests" |
||||
needs: deploy-infra |
||||
runs-on: ubuntu-latest |
||||
steps: |
||||
- name: "Checkout" |
||||
uses: actions/checkout@v2 |
||||
|
||||
- name: "Validate site is running" |
||||
run: .github/scripts/url-check.sh -u https://${{ env.APP_NAME }}.azurewebsites.net/ -s "Python" -t 200 |
||||
|
||||
# - name: "Run API tests" |
||||
# run: | |
||||
# npm install newman --silent |
||||
# node_modules/newman/bin/newman.js run src/tests/postman_collection.json --global-var apphost=${{ env.APP_NAME }}.azurewebsites.net |
||||
|
||||
- name: "End deployment - success" |
||||
if: ${{ success() }} |
||||
uses: chrnorm/deployment-status@v1.0.0 |
||||
with: |
||||
token: ${{ github.token }} |
||||
state: success |
||||
deployment_id: ${{ needs.deploy-infra.outputs.deployment_id }} |
||||
environment_url: https://${{ env.APP_NAME }}.azurewebsites.net/ |
||||
|
||||
- name: "End deployment - failure" |
||||
if: ${{ failure() }} |
||||
uses: chrnorm/deployment-status@v1.0.0 |
||||
with: |
||||
token: ${{ github.token }} |
||||
state: failure |
||||
deployment_id: ${{ needs.deploy-infra.outputs.deployment_id }} |
@ -1,78 +0,0 @@
@@ -1,78 +0,0 @@
|
||||
name: CI Build App |
||||
|
||||
on: |
||||
push: |
||||
branches: [master] |
||||
paths-ignore: |
||||
- ".github/**" |
||||
pull_request: |
||||
|
||||
env: |
||||
IMAGE_REG: ghcr.io |
||||
IMAGE_REPO: benc-uk/python-demoapp |
||||
|
||||
jobs: |
||||
test: |
||||
name: "Tests & Linting" |
||||
runs-on: ubuntu-latest |
||||
steps: |
||||
- name: "Checkout" |
||||
uses: actions/checkout@v2 |
||||
|
||||
- name: "Test/linting stub" |
||||
run: echo "Nothing here 😐" |
||||
|
||||
# - name: "Upload test results" |
||||
# uses: actions/upload-artifact@v2 |
||||
# with: |
||||
# name: test-results |
||||
# path: ./src/test-results.xml |
||||
# - name: "Report on test results" |
||||
# uses: ashley-taylor/junit-report-annotations-action@master |
||||
# if: always() |
||||
# with: |
||||
# access-token: ${{ secrets.GITHUB_TOKEN }} |
||||
# path: ./src/test-results.xml |
||||
# name: Unit test results |
||||
|
||||
build: |
||||
name: "Build & Push Image" |
||||
needs: test |
||||
runs-on: ubuntu-latest |
||||
steps: |
||||
- name: "Checkout" |
||||
uses: actions/checkout@v2 |
||||
|
||||
- name: "Create datestamp image tag" # Nicer than using github runid, I think |
||||
run: echo "IMAGE_TAG=$(date +%d-%m-%Y.%H%M)" >> $GITHUB_ENV |
||||
|
||||
- name: "Docker build image" |
||||
run: docker build . -t $IMAGE_REG/$IMAGE_REPO:$IMAGE_TAG |
||||
|
||||
- name: "Login to GitHub container registry" |
||||
if: github.ref == 'refs/heads/master' |
||||
uses: docker/login-action@v1 |
||||
with: |
||||
registry: ${{ env.IMAGE_REG }} |
||||
username: ${{ github.repository_owner }} |
||||
password: ${{ secrets.CR_PAT }} |
||||
|
||||
- name: "Docker push image to ${{ env.IMAGE_REG }}" |
||||
if: github.ref == 'refs/heads/master' |
||||
run: docker push $IMAGE_REG/$IMAGE_REPO |
||||
|
||||
- name: "Trigger AKS release pipeline" |
||||
if: github.ref == 'refs/heads/master' |
||||
uses: benc-uk/workflow-dispatch@v1 |
||||
with: |
||||
workflow: "CD Release - AKS" |
||||
token: ${{ secrets.CR_PAT }} |
||||
inputs: '{ "IMAGE_TAG": "${{ env.IMAGE_TAG }}" }' |
||||
|
||||
- name: "Trigger Azure web app release pipeline" |
||||
if: github.ref == 'refs/heads/master' |
||||
uses: benc-uk/workflow-dispatch@v1 |
||||
with: |
||||
workflow: "CD Release - Webapp" |
||||
token: ${{ secrets.CR_PAT }} |
||||
inputs: '{ "IMAGE_TAG": "${{ env.IMAGE_TAG }}" }' |
@ -1,31 +0,0 @@
@@ -1,31 +0,0 @@
|
||||
name: Release Versioned Image |
||||
|
||||
on: |
||||
workflow_dispatch: |
||||
release: |
||||
types: [published] |
||||
|
||||
env: |
||||
IMAGE_REG: ghcr.io |
||||
IMAGE_REPO: benc-uk/python-demoapp |
||||
|
||||
jobs: |
||||
publish-image: |
||||
name: "Build & Publish" |
||||
runs-on: ubuntu-latest |
||||
steps: |
||||
- name: "Checkout" |
||||
uses: actions/checkout@v2 |
||||
|
||||
- name: "Docker build image with version tag" |
||||
run: docker build . -t $IMAGE_REG/$IMAGE_REPO:latest -t $IMAGE_REG/$IMAGE_REPO:${{ github.event.release.tag_name }} |
||||
|
||||
- name: "Login to GitHub container registry" |
||||
uses: docker/login-action@v1 |
||||
with: |
||||
registry: ${{ env.IMAGE_REG }} |
||||
username: ${{ github.repository_owner }} |
||||
password: ${{ secrets.CR_PAT }} |
||||
|
||||
- name: "Docker push image to ${{ env.IMAGE_REG }}" |
||||
run: docker push $IMAGE_REG/$IMAGE_REPO |
Loading…
Reference in new issue