From 8f2c838f46574eb2a217c87f251f0d6f62914ba4 Mon Sep 17 00:00:00 2001
From: Christian Rebischke <chris@nullday.de>
Date: Wed, 28 Aug 2019 01:01:10 +0200
Subject: [PATCH] created generic-ci script and refactored file permissions

set executables executable and created a generic-ci.sh script.
With this script we are able to use travis or github actions
or any other ci system.

Signed-off-by: Christian Rebischke <chris@nullday.de>
---
 .github/workflows/main.yml | 17 +++++++++++++++++
 controller.py              |  0
 generic-ci.sh              | 32 ++++++++++++++++++++++++++++++++
 3 files changed, 49 insertions(+)
 create mode 100644 .github/workflows/main.yml
 mode change 100644 => 100755 controller.py
 create mode 100755 generic-ci.sh

diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
new file mode 100644
index 0000000..2242593
--- /dev/null
+++ b/.github/workflows/main.yml
@@ -0,0 +1,17 @@
+name: CI
+
+on: [push]
+
+jobs:
+  build:
+
+    runs-on: ubuntu-latest
+    
+    steps:
+    - uses: actions/checkout@v1
+    - name: install packer
+      run:
+        ./generic-ci.sh install
+    - name: verify packer configuration
+      run:
+        ./generic-ci.sh verify
diff --git a/controller.py b/controller.py
old mode 100644
new mode 100755
diff --git a/generic-ci.sh b/generic-ci.sh
new file mode 100755
index 0000000..0fb7ce6
--- /dev/null
+++ b/generic-ci.sh
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+case $1 in
+
+  install)
+    PACKER_CURRENT_VERSION="$(curl -s https://checkpoint-api.hashicorp.com/v1/check/packer | jq -r -M '.current_version')"
+    PACKER_URL="https://releases.hashicorp.com/packer/$PACKER_CURRENT_VERSION/packer_${PACKER_CURRENT_VERSION}_linux_amd64.zip"
+    PACKER_SHA256="https://releases.hashicorp.com/packer/$PACKER_CURRENT_VERSION/packer_${PACKER_CURRENT_VERSION}_SHA256SUMS"
+    PACKER_SHA256_SIG="https://releases.hashicorp.com/packer/$PACKER_CURRENT_VERSION/packer_${PACKER_CURRENT_VERSION}_SHA256SUMS.sig"
+    HASHICORP_FINGERPRINT=91a6e7f85d05c65630bef18951852d87348ffc4c
+    HASHICORP_KEY="https://keybase.io/hashicorp/pgp_keys.asc?fingerprint=${HASHICORP_FINGERPRINT}"
+    wget "${PACKER_URL}"
+    wget "${PACKER_SHA256}"
+    wget "${PACKER_SHA256_SIG}"
+    wget -O hashicorp.key "${HASHICORP_KEY}"
+    gpg --with-fingerprint --with-colons hashicorp.key | grep ${HASHICORP_FINGERPRINT^^}
+    gpg --import hashicorp.key
+    gpg --verify "packer_${PACKER_CURRENT_VERSION}_SHA256SUMS.sig" "packer_${PACKER_CURRENT_VERSION}_SHA256SUMS"
+    grep "linux_amd64 packer_${PACKER_CURRENT_VERSION}_SHA256SUMS" >packer_SHA256SUM_linux_amd64
+    sha256sum --check --status packer_SHA256SUM_linux_amd64
+    unzip "packer_${PACKER_CURRENT_VERSION}_linux_amd64.zip"
+    ;;
+
+  verify)
+    ./packer --version
+    jq ".\"post-processors\"[0] |= map(select(.\"type\" != \"vagrant-cloud\"))" vagrant.json | ./packer validate -var "iso_url=https://downloads.archlinux.de/iso/$(date +'%Y.%m').01/archlinux-$(date +'%Y.%m').01-x86_64.iso" -var "iso_checksum_url=https://downloads.archlinux.de/iso/$(date +'%Y.%m').01/sha1sums.txt" -
+    ;;
+
+  *)
+    exit 1
+    ;;
+esac
-- 
GitLab