Compare commits

..

18 Commits

Author SHA1 Message Date
drunkendog 3b60243670 Build Actions image if Dockerfile changed, only build Actions image if change is on main branch 2023-08-28 18:52:13 +01:00
drunkendog 40267968d6 Add nodejs to Actions Dockerfile 2023-08-28 18:41:38 +01:00
drunkendog 682a8337f3 Set docker image cache time to 86400 2023-08-28 18:33:21 +01:00
drunkendog f97ad87d70 Add secrets to docker build Action 2023-08-28 18:29:38 +01:00
drunkendog 7d6b234e8f Fix outputting in build script 2023-08-28 18:22:32 +01:00
drunkendog 4bc862a047 Fix output issue 2023-08-28 18:09:52 +01:00
drunkendog 789aa3b79a Fix output issue in docker build Actions 2023-08-28 18:08:50 +01:00
drunkendog ea53ea31bb Add jq installation step 2023-08-28 18:06:04 +01:00
drunkendog e015dda3a4 Fix redundant code 2023-08-28 18:02:04 +01:00
drunkendog b97c67ba4a Add .gitea/workflows/build-base-image.yaml 2023-08-28 18:01:11 +01:00
drunkendog ae478fda9d Escape # 2023-08-28 17:37:56 +01:00
drunkendog bd877ba9e4 Add `cd` to current directory 2023-08-28 17:37:30 +01:00
drunkendog a155d9199a Add --prefix check and rename code quality test to make it consistent (see #1) 2023-08-28 17:29:26 +01:00
drunkendog 33b314a081 Add actions/build-docker-image.sh 2023-08-28 17:24:46 +01:00
drunkendog 7b7b8a6644 Remove apt-upgrade and delete unnecessary apt files 2023-08-28 17:23:02 +01:00
drunkendog 1049c4e0e4 Replace cleanup step for hello-world with --rm 2023-08-28 17:07:59 +01:00
drunkendog 9249435290 Fix typo in dockerfile 2023-08-28 17:04:01 +01:00
drunkendog 8e762f3965 Add post-pull to docker-compose 2023-08-28 16:35:13 +01:00
6 changed files with 72 additions and 19 deletions

View File

@ -0,0 +1,42 @@
name: Build Docker Image for Actions
on: [push]
if: github.ref == 'refs/heads/main'
jobs:
Check-If-Rebuild:
runs-on: ubuntu-22.04
env:
DEBIAN_FRONTEND: noninteractive
outputs:
last-time: ${{ steps.last-time.outputs.last-time }}
dockerfile-changed: ${{ steps.dockerfile-changed.outputs.dockerfile-changed }}
steps:
- name: Install jq
run: |
apt-get update -y
apt-get install -y jq
- name: Check last repository build time
id: last-time
run: curl -s https://hub.docker.com/v2/repositories/drunkendog/standard-build-actions/tags/latest
| jq '.last_updated'
| xargs -i date --date {} +%s
| xargs -i expr $(date +%s) - {}
| xargs -i echo last-time={} >> $GITHUB_OUTPUT
- name: Check if Dockerfile changed
id: dockerfile-changed
run: |
if ${{ github.event_name == 'pull_request' }}; then
echo dockerfile-changed=$(git diff --name-only -r HEAD^1 HEAD | grep -x actions/Dockerfile | wc -l) >> $GITHUB_OUTPUT
else
echo dockerfile-changed=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | grep -x actions/Dockerfile | wc -l) >> $GITHUB_OUTPUT
fi
Build-Image:
needs: [Check-If-Rebuild]
if: needs.Check-If-Rebuild.outputs.last-time > 86400 || needs.Check-If-Rebuild.outputs.dockerfile-changed == 1
runs-on: ubuntu-22.04
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Get Docker
run: curl -sL get.docker.io | bash
- name: Build and upload image
run: sh actions/build-docker-image.sh ${{ secrets.DOCKER_USERNAME }} ${{ secrets.DOCKER_TOKEN }}

View File

@ -1,13 +0,0 @@
name: Code Quality Test
on: [push, pull_request]
jobs:
Quality-Check:
runs-on: ubuntu-22.04
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Check for os.system (#2)
continue-on-error: true
run: |
git ls-files | xargs grep os.system
exit $(git ls-files | xargs grep os.system | wc -l)

View File

@ -0,0 +1,18 @@
name: Code Quality Test
on: [push, pull_request]
jobs:
Quality-Check:
runs-on: ubuntu-22.04
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Check for --prefix in Borg commands (\#1)
continue-on-error: true
run: |
git ls-files backup/ | xargs grep '\-\-prefix'
exit $(git ls-files backup/ | xargs grep '\-\-prefix' | wc -l)
- name: Check for os.system (\#2)
continue-on-error: true
run: |
git ls-files | xargs grep os.system
exit $(git ls-files | xargs grep os.system | wc -l)

View File

@ -11,9 +11,8 @@ jobs:
run: |
sh setup.sh
sh scripts/get-docker.sh
sh post-pull.sh
- name: Check if Docker was installed
run: docker run --name hello-world hello-world
- name: Clean up hello-world container
run: docker rm hello-world
- name: Clean up network (see #3)
run: docker run --rm --name hello-world hello-world
- name: Clean up network (see \#3)
run: docker network rm main_subnet

View File

@ -1,4 +1,4 @@
FROM ubuntu-22.04
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update -y && apt-get upgrade -y && apt-get install -y ca-certificates curl gnupg lsb-release nano wget tmux htop python3 python3-pip git certbot borgbackup jq
RUN apt-get update -y && apt-get install -y ca-certificates curl gnupg lsb-release nano wget tmux htop python3 python3-pip git certbot borgbackup jq nodejs && rm -rf /var/lib/apt/lists/*
CMD ["/bin/bash"]

View File

@ -0,0 +1,7 @@
#!/bin/bash
cd "${0%/*}"
docker login --username $1 --password $2
docker build -t drunkendog/standard-build-actions .
docker push drunkendog/standard-build-actions