-
Notifications
You must be signed in to change notification settings - Fork 1
62 lines (52 loc) · 2.76 KB
/
create-image.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
# This is a basic workflow to help you get started with Actions
name: CI
env:
S3_ENDPOINT: ${{ vars.S3_ENDPOINT }}
ACCESS_KEY: ${{ secrets.ACCESS_KEY }}
SECRET_KEY: ${{ secrets.SECRET_KEY }}
S3_ALIAS: ${{ secrets.S3_ALIAS }}
S3_BUCKET: ${{ vars.S3_BUCKET }}
# Controls when the workflow will run
on:
push:
tags:
- '*'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: [ self-hosted, freebsd ]
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: actions/checkout@v4
- name: Get tag name
run: echo "REF_NAME=$(echo ${GITHUB_REF##*/} | tr / -)" >> $GITHUB_ENV
- name: Debug
run: echo ${{ env.REF_NAME }}
# Run building script
- name: Run build.sh
run: |
export PATH=/usr/local/bin/:$PATH
sudo chmod +x build.sh
sudo ./build.sh ${{ env.REF_NAME }}
# Converting image
- name: Converting image to QCOW2 format
run: |
sudo qemu-img convert -f raw -O qcow2 -c -S 4k final.raw freebsd-${{ env.REF_NAME }}-amd64.qcow2
sudo md5sum freebsd-${{ env.REF_NAME }}-amd64.qcow2 > md5.txt
sudo sha1sum -b freebsd-${{ env.REF_NAME }}-amd64.qcow2 > sha1.txt
sudo sha256sum -b freebsd-${{ env.REF_NAME }}-amd64.qcow2 > sha256.txt
- name: Uploading image in object storage
run: |
echo "Uploading image in object storage"
minio-client alias set ${{ env.S3_ALIAS }} ${{ env.S3_ENDPOINT }} ${{ env.ACCESS_KEY }} ${{ env.SECRET_KEY }}
minio-client cp freebsd-${{ env.REF_NAME }}-amd64.qcow2 ${{ env.S3_ALIAS }}/${{ env.S3_BUCKET }}/latest/freebsd-latest-amd64.qcow2
minio-client cp md5.txt ${{ env.S3_ALIAS }}/${{ env.S3_BUCKET }}/latest/md5.txt
minio-client cp sha1.txt ${{ env.S3_ALIAS }}/${{ env.S3_BUCKET }}/latest/sha1.txt
minio-client cp sha256.txt ${{ env.S3_ALIAS }}/${{ env.S3_BUCKET }}/latest/sha256.txt
minio-client cp ${{ env.S3_ALIAS }}/${{ env.S3_BUCKET }}/latest/freebsd-latest-amd64.qcow2 ${{ env.S3_ALIAS }}/${{ env.S3_BUCKET }}/${{ env.REF_NAME }}/freebsd-${{ env.REF_NAME }}-amd64.qcow2
minio-client cp ${{ env.S3_ALIAS }}/${{ env.S3_BUCKET }}/latest/md5.txt ${{ env.S3_ALIAS }}/${{ env.S3_BUCKET }}/${{ env.REF_NAME }}/md5.txt
minio-client cp ${{ env.S3_ALIAS }}/${{ env.S3_BUCKET }}/latest/sha1.txt ${{ env.S3_ALIAS }}/${{ env.S3_BUCKET }}/${{ env.REF_NAME }}/sha1.txt
minio-client cp ${{ env.S3_ALIAS }}/${{ env.S3_BUCKET }}/latest/sha256.txt ${{ env.S3_ALIAS }}/${{ env.S3_BUCKET }}/${{ env.REF_NAME }}/sha256.txt