-
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.
First shot at adding/testing github workflow to update containers. (#1)
* 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
Showing
5 changed files
with
128 additions
and
4 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 |
---|---|---|
@@ -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 |
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,2 @@ | ||
.env | ||
env |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,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" |