build-ci #3074
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
name: build-ci | |
on: | |
schedule: | |
- cron: 0 22 * * * | |
push: | |
branches: | |
- main | |
pull_request: | |
jobs: | |
build-all-artifacts: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Export tag | |
id: export_tag | |
run: | | |
git describe --abbrev=0 --tags | |
TAG=`git describe --abbrev=0 --tags 2>/dev/null || echo "v0.0.0"` | |
echo "elemental_tag=$TAG" >> $GITHUB_OUTPUT | |
- name: Install dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y genisoimage | |
- name: Build image | |
run: | | |
make build | |
make dump_image | |
- name: Build iso | |
run: | | |
make iso | |
- name: Cache artifacts | |
uses: actions/cache@v3 | |
env: | |
cache-name: cache-artifacts | |
with: | |
path: build/* | |
key: build-ci-${{ github.event.pull_request.head.sha || github.sha }} | |
- name: Send failed status to slack (only on schedule) | |
if: failure() && github.event_name == 'schedule' | |
uses: slackapi/[email protected] | |
with: | |
payload: | | |
{ | |
"blocks": [ | |
{ | |
"type": "section", | |
"text": { | |
"type": "mrkdwn", | |
"text": "Workflow build-ci ${{ github.job }}" | |
}, | |
"accessory": { | |
"type": "button", | |
"text": { | |
"type": "plain_text", | |
"text": ":github:", | |
"emoji": true | |
}, | |
"url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
} | |
} | |
] | |
} | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK | |
upload-all-artifacts: | |
needs: build-all-artifacts | |
runs-on: ubuntu-latest | |
steps: | |
- name: Restore cache artifacts | |
uses: actions/cache@v3 | |
env: | |
cache-name: cache-artifacts | |
with: | |
path: build/* | |
key: build-ci-${{ github.event.pull_request.head.sha || github.sha }} | |
- name: Upload docker image | |
uses: actions/upload-artifact@v3 | |
with: | |
name: docker-image | |
path: build/*.tar | |
- name: Upload ISO | |
uses: actions/upload-artifact@v3 | |
with: | |
name: iso-image | |
path: build/*.iso |