Skip to content

Commit

Permalink
First shot at adding/testing github workflow to update containers. (#1)
Browse files Browse the repository at this point in the history
* first shot at adding/testing github workflow to update containers.
After this we will want to have builds for all the newly generated (or changed) files,
but just to test. Only on merge will they be build -> deploy

Signed-off-by: vsoch <[email protected]>
  • Loading branch information
vsoch authored Aug 31, 2021
1 parent b1783cb commit cbaab51
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 4 deletions.
109 changes: 109 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: Docker Updates

# TODO this will be a regularly run job to update images
# TODO we need an easy way to detect new and changes files in the PR and then
# put them into a build matrix
on:
pull_request: []
push:
branches:
- main

jobs:
update:
runs-on: ubuntu-latest
outputs:
dockerfile_matrix: ${{ steps.dockerfile_check.outputs.dockerfile_matrix }}
steps:
- name: Checkout Actions Repository
uses: actions/checkout@v2

- name: Add new Dockerfiles for build
uses: vsoch/uptodate@main
with:
root: .
parser: dockerhierarchy

- name: Update existing Dockerfile hashes
uses: vsoch/uptodate@main
id: dockerfile_check
with:
root: .
parser: dockerfile

build:
needs:
- update
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
result: ${{ fromJson(needs.update.outputs.dockerfile_matrix) }}

name: "Build ${{ matrix.result.name }}"
steps:
- name: Checkout Repository
uses: actions/checkout@v2

- name: GHCR Login
if: (github.event_name != 'pull_request')
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ secrets.GHCR_USERNAME }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Make Space For Build
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
# This currently has a lot of extra prints for debugging
- name: Build ${{ matrix.result.name }}
id: builder
run: |
basedir=$(dirname ${{ matrix.result.name }})
printf "Base directory is ${basedir}\n"
dockerfile=$(basename ${{ matrix.result.name }})
printf "Dockerfile basename is ${dockerfile}\n"
tag=$(basename ${basedir})
printf "Tag is ${tag}\n"
container=$(basename $(dirname $basedir))
printf "Container is ${container}\n"
cat ${{ matrix.result.name }}
cd $basedir
docker build -f Dockerfile -t ghcr.io/rse-radiuss/${container}:${tag} .
echo ::set-output name=container::ghcr.io/rse-radiuss/${container}:${tag}
# TODO this and size should be saved to site / gh-pages, for something like autamus librarian!
# We will test out, if it's a push to main, pushing updated recipes
# This should not trigger a second time, since the token is not a PAT
- name: Update Recipes
if: (github.event_name != 'pull_request')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
printf "GitHub Actor: ${GITHUB_ACTOR}\n"
git config --global user.name "github-actions"
git config --global user.email "[email protected]"
git add .
git status | grep "modified\|new file"
if [ $? -eq 0 ]; then
printf "Changes\n"
git commit -m "Automated push to update containers $(date '+%Y-%m-%d')" || exit 0
git push origin main
else
printf "No changes\n"
fi
- name: Deploy Container
if: (github.event_name != 'pull_request')
env:
container: ${{ steps.builder.outputs.container }}
run: |
docker images
printf "docker push ${{ env.container }} --all-tags\n"
docker push ${{ env.container }} --all-tags
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.env
env
Binary file modified img/rse-radiuss-docker.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions ubuntu/20.04/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ RUN python3 -m pip install --upgrade pip && \

# Install cmake
RUN wget -q --no-check-certificate https://cmake.org/files/v3.18/cmake-3.18.6-Linux-x86_64.tar.gz && \
tar -xzf cmake-3.18.6-Linux-x86_64.tar.gz
rm -r cmake-3.18.6-Linux-x86_64/share/vim/vimfiles
cp -fR cmake-3.18.6-Linux-x86_64/* /usr
rm -rf cmake-3.18.6-Linux-x86_64
tar -xzf cmake-3.18.6-Linux-x86_64.tar.gz && \
rm -r cmake-3.18.6-Linux-x86_64/share/vim/vimfiles && \
cp -fR cmake-3.18.6-Linux-x86_64/* /usr && \
rm -rf cmake-3.18.6-Linux-x86_64 && \
rm cmake-3.18.6-Linux-x86_64.tar.gz
13 changes: 13 additions & 0 deletions ubuntu/uptodate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
dockerhierarchy:
container:
name: ubuntu
filter:
# we only want XX.04 versions
- "^[0-9]+[.]04$"
startat: "16.04"

# Versions to skip (not LTS releases)
skips:
- "17.04"
- "19.04"
- "21.04"

0 comments on commit cbaab51

Please sign in to comment.