Build Docker images #772
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
name: "Build Docker images" | |
on: | |
push: | |
branches: | |
- master | |
schedule: | |
- cron: "0 12 * * 0,2,4,6" | |
env: | |
PYTHON_3_8_IMAGE: "3.8.20" | |
PYTHON_3_8_TAGS: "3.8.20 3.8" | |
PYTHON_3_9_IMAGE: "3.9.20" | |
PYTHON_3_9_TAGS: "3.9.20 3.9" | |
PYTHON_3_10_IMAGE: "3.10.15" | |
PYTHON_3_10_TAGS: "3.10.15 3.10" | |
PYTHON_3_11_IMAGE: "3.11.10" | |
PYTHON_3_11_TAGS: "3.11.10 3.11" | |
PYTHON_3_12_IMAGE: "3.12.6" | |
PYTHON_3_12_TAGS: "3.12.6 3.12 ." | |
#PYTHON_3_13_IMAGE: "3.13.0rc2" | |
#PYTHON_3_13_TAGS: "3.13.0rc2 3.13.0 3.13" | |
jobs: | |
setup: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python 3.12 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
- name: Ensure login succeeds for Docker Hub and GitHub registry | |
shell: bash | |
run: | | |
echo "${{ secrets.DOCKER_LOGIN_PASSWORD }}" | docker login --username "${{ secrets.DOCKER_LOGIN_USERNAME }}" --password-stdin | |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin | |
- name: Always regenerate dockerfiles folder | |
shell: bash | |
run: | | |
rm -rf dockerfiles | |
pip install -U pip | |
pip install -U -r requirements.txt | |
python generate.py | |
cd dockerfiles | |
find ./ -name "*.sh" -exec chmod +x {} \; | |
cd .. | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: dockerfiles-1 | |
path: dockerfiles | |
minimal: | |
runs-on: ubuntu-latest | |
needs: setup | |
strategy: | |
max-parallel: 8 | |
matrix: | |
python-version: [3_8, 3_9, 3_10, 3_11, 3_12] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: dockerfiles-1 | |
path: dockerfiles | |
- name: Build minimal containers | |
shell: bash | |
run: | | |
export GIT_HEAD="`git rev-list --count HEAD || echo unknown`+`git rev-parse --short HEAD || echo unknown`" | |
echo "${{ secrets.DOCKER_LOGIN_PASSWORD }}" | docker login --username "${{ secrets.DOCKER_LOGIN_USERNAME }}" --password-stdin | |
cd dockerfiles | |
find ./ -name "*.sh" -exec chmod +x {} \; | |
./deploy_target.sh 0_minimal ${PYTHON_${{ matrix.python-version }}_IMAGE} | |
cd .. | |
full: | |
runs-on: ubuntu-latest | |
needs: minimal | |
strategy: | |
max-parallel: 8 | |
matrix: | |
python-version: [3_8, 3_9, 3_10, 3_11, 3_12] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: dockerfiles-1 | |
path: dockerfiles | |
- name: Build full containers | |
shell: bash | |
run: | | |
export GIT_HEAD="`git rev-list --count HEAD || echo unknown`+`git rev-parse --short HEAD || echo unknown`" | |
echo "${{ secrets.DOCKER_LOGIN_PASSWORD }}" | docker login --username "${{ secrets.DOCKER_LOGIN_USERNAME }}" --password-stdin | |
cd dockerfiles | |
find ./ -name "*.sh" -exec chmod +x {} \; | |
./deploy_target.sh 1_full ${PYTHON_${{ matrix.python-version }}_IMAGE} | |
cd .. | |
extras: | |
runs-on: ubuntu-latest | |
needs: full | |
strategy: | |
max-parallel: 8 | |
matrix: | |
python-version: [3_8, 3_9, 3_10, 3_11, 3_12] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: dockerfiles-1 | |
path: dockerfiles | |
- name: Build extras containers | |
shell: bash | |
run: | | |
export GIT_HEAD="`git rev-list --count HEAD || echo unknown`+`git rev-parse --short HEAD || echo unknown`" | |
echo "${{ secrets.DOCKER_LOGIN_PASSWORD }}" | docker login --username "${{ secrets.DOCKER_LOGIN_USERNAME }}" --password-stdin | |
cd dockerfiles | |
find ./ -name "*.sh" -exec chmod +x {} \; | |
./deploy_target.sh 2_extra ${PYTHON_${{ matrix.python-version }}_IMAGE} | |
cd .. | |
final: | |
runs-on: ubuntu-latest | |
needs: extras | |
strategy: | |
max-parallel: 8 | |
matrix: | |
python-version: [3_8, 3_9, 3_10, 3_11, 3_12] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: dockerfiles-1 | |
path: dockerfiles | |
- name: Build final containers | |
shell: bash | |
run: | | |
export GIT_HEAD="`git rev-list --count HEAD || echo unknown`+`git rev-parse --short HEAD || echo unknown`" | |
echo "${{ secrets.DOCKER_LOGIN_PASSWORD }}" | docker login --username "${{ secrets.DOCKER_LOGIN_USERNAME }}" --password-stdin | |
cd dockerfiles | |
find ./ -name "*.sh" -exec chmod +x {} \; | |
./deploy_target.sh discordpy ${PYTHON_${{ matrix.python-version }}_IMAGE} | |
cd .. |