Skip to content

Commit

Permalink
update workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
vlaszdunov committed Jun 2, 2024
1 parent 4f18ed1 commit ad368e7
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 52 deletions.
51 changes: 37 additions & 14 deletions .github/workflows/Publisher.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@ name: build and push
run-name: Build and push Python images to GHCR

on:
push:
schedule:
- cron: 0 0 * * *
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-publish:
Setup-Dckerfiles:
permissions:
contents: read
packages: write
id-token: write


runs-on: ubuntu-latest
steps:
Expand All @@ -27,16 +29,37 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build Python Images
run: |
docker build . --target III.X --tag ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:3.10
docker build . --target III.XI --tag ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:3.11
docker build . --target III.XII --tag ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:3.12
docker build . --target latest --tag ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:latest
- name: Publish Python Images
run: |
docker push ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:3.10
docker push ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:3.11
docker push ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:3.12
docker push ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:latest
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: latest

- name: install dependencies
run: pip install -r requirements.txt

- name: Create Dockerfiles of Python Images
run: python /src/parse.py

matrix_input:
needs: Setup-Dckerfiles
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: danyow/[email protected]
id: array
with:
cmd: ls Python_dockerfiles
separator: newline
outputs:
param: ${{ steps.array.outputs.build }}

dynamic_matrix:
needs:
- matrix_input
strategy:
matrix:
param: ${{ fromJson(needs.matrix_input.outputs.param) }}
runs-on: ubuntu-latest
steps:
- run: |
echo ${{ matrix.param }}
36 changes: 0 additions & 36 deletions src/create_dockerfile.py

This file was deleted.

6 changes: 4 additions & 2 deletions src/parse.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import requests
from bs4 import BeautifulSoup as bs
import re
import os

URL = 'https://www.python.org/downloads/'

Expand All @@ -27,7 +28,6 @@


actual_stable_releases_links = []

for actual_release in active_releases_list:
for link in releases_download_links:
check = re.fullmatch(r'.*Python-\d*.\d*.?\d*.tgz', link)
Expand All @@ -37,10 +37,12 @@
break

Dockerfile_temp = open('Dockerfile.template').read()
if os.path.exists('Python_dockerfiles')==False:
os.mkdir('Python_dockerfiles')
for link in actual_stable_releases_links:
py_version = re.search(r'\d+.\d+.?\d*', link)[0]
py_short_version = re.search(r'\d+.\d+', py_version)[0]
Dockerfile = Dockerfile_temp.format(python_link=link,
python_version=py_version,
python_short_version=py_short_version)
open(f'Dockerfile_{py_version}','w').write(Dockerfile)
open(f'Python_dockerfiles/Dockerfile_{py_version}','w').write(Dockerfile)

0 comments on commit ad368e7

Please sign in to comment.