-
Notifications
You must be signed in to change notification settings - Fork 6
124 lines (124 loc) · 5.7 KB
/
vagrant-box-archivematica.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
name: Archivematica Vagrant box
on:
workflow_dispatch:
inputs:
version:
description: Version (e.g. 1.13.0-rc.2)
required: true
description:
description: Description
required: true
jobs:
build-base-image:
name: "Build base image Ubuntu ${{ matrix.ubuntu-version }}"
runs-on: ubuntu-24.04
env:
PACKER_CACHE_DIR: ${{ github.workspace }}/.packer_cache
PACKER_LOG: TRACE
strategy:
fail-fast: false
matrix:
ubuntu-version: [
"20.04",
]
steps:
- name: Check out code
uses: actions/checkout@v4
- name: "Install packer and VirtualBox"
run: |
wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
wget -O- https://www.virtualbox.org/download/oracle_vbox_2016.asc | sudo gpg --yes --output /usr/share/keyrings/oracle-virtualbox-2016.gpg --dearmor
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/oracle-virtualbox-2016.gpg] https://download.virtualbox.org/virtualbox/debian $(lsb_release -cs) contrib" | sudo tee /etc/apt/sources.list.d/virtualbox.list
sudo apt update && sudo apt install packer virtualbox-7.1
- name: Set the user environment as VirtualBox expects it
run: |
echo "USER=$USER" >> $GITHUB_ENV
echo "LOGNAME=$USER" >> $GITHUB_ENV
- name: Build
run: |
cd "${{ github.workspace }}/packer/templates/vagrant-base-ubuntu-${{ matrix.ubuntu-version }}-amd64"
packer init template.json.pkr.hcl
packer build -on-error=abort template.json.pkr.hcl
- name: Upload base image
uses: actions/upload-artifact@v4
with:
name: "base-image-${{ matrix.ubuntu-version }}"
path: "${{ github.workspace }}/packer/builds/virtualbox/vagrant-base-ubuntu-${{ matrix.ubuntu-version }}-amd64"
vagrant-box-archivematica:
name: "Build and upload box image Ubuntu ${{ matrix.ubuntu-version }}"
runs-on: ubuntu-24.04
needs: ["build-base-image"]
env:
PACKER_CACHE_DIR: ${{ github.workspace }}/.packer_cache
PACKER_LOG: TRACE
strategy:
fail-fast: false
matrix:
ubuntu-version: [
"20.04",
]
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Restore base image
uses: actions/download-artifact@v4
with:
name: "base-image-${{ matrix.ubuntu-version }}"
path: "${{ github.workspace }}/packer/builds/virtualbox/vagrant-base-ubuntu-${{ matrix.ubuntu-version }}-amd64"
- name: "Install packer, vagrant and VirtualBox"
run: |
wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
wget -O- https://www.virtualbox.org/download/oracle_vbox_2016.asc | sudo gpg --yes --output /usr/share/keyrings/oracle-virtualbox-2016.gpg --dearmor
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/oracle-virtualbox-2016.gpg] https://download.virtualbox.org/virtualbox/debian $(lsb_release -cs) contrib" | sudo tee /etc/apt/sources.list.d/virtualbox.list
sudo apt update && sudo apt install packer vagrant virtualbox-7.1
- name: Set the user environment as VirtualBox expects it
run: |
echo "USER=$USER" >> $GITHUB_ENV
echo "LOGNAME=$USER" >> $GITHUB_ENV
- name: Update vbox networks
run: |
sudo mkdir -p /etc/vbox/
echo "* 10.10.10.20/24" | sudo tee -a /etc/vbox/networks.conf
- name: Build
run: |
cd ${{ github.workspace }}/packer/templates/vagrant-box-archivematica
packer init template.json.pkr.hcl
packer build -on-error=abort template.json.pkr.hcl
mv ${{ github.workspace }}/packer/builds/virtualbox/vagrant-am.box \
${{ github.workspace }}/archivematica-vagrant-${{ github.event.inputs.version }}.box
- name: Provision a test VM with the new image
run: |
vagrant init --minimal --no-tty archivematica-vagrant-${{ github.event.inputs.version }} file://${{ github.workspace }}/archivematica-vagrant-${{ github.event.inputs.version }}.box
cat Vagrantfile
vagrant up --debug-timestamp --provider virtualbox
- name: Test AM is running in the test VM
run: |
sleep 180
test $( \
curl \
--silent \
--header 'Authorization: ApiKey admin:this_is_the_am_api_key' \
--header 'Content-Type: application/json' \
'http://10.10.10.20/api/processing-configuration/' \
| jq -r '.processing_configurations == ["automated", "default"]' \
) == true
test $( \
curl \
--silent \
--header 'Authorization: ApiKey admin:this_is_the_ss_api_key' \
--header 'Content-Type: application/json' \
'http://10.10.10.20:8000/api/v2/pipeline/' \
| jq -r '.meta.total_count == 1' \
) == true
- name: Upload
run: |
cd ${{ github.workspace }}/tools/vagrant-box-uploader
bundle install
ruby upload.rb \
archivematica \
'${{ github.workspace }}/archivematica-vagrant-${{ github.event.inputs.version }}.box' \
'${{ secrets.VAGRANT_CLOUD }}' \
'${{ github.event.inputs.version }}' \
'${{ github.event.inputs.description }}'