Skip to content

Merge pull request #755 from NethServer/feat-7173 #3881

Merge pull request #755 from NethServer/feat-7173

Merge pull request #755 from NethServer/feat-7173 #3881

Workflow file for this run

name: core
on:
push:
branches:
- '**'
tags-ignore:
- ns8-stable
paths-ignore:
- 'docs/**'
- 'infra/**'
- 'core/tests/**'
- 'core/test-module.sh'
workflow_dispatch:
jobs:
module:
uses: NethServer/ns8-github-actions/.github/workflows/module-info.yml@main
push_image:
env:
REPONAME: ${{needs.module.outputs.name}}
IMAGETAG: ${{needs.module.outputs.tag}}
name: 'Build ${{ github.workflow }}'
runs-on: ubuntu-latest
needs:
- module
steps:
- id: info
name: "Retrieve runtime information"
run: |
echo "images-dir=$(buildah info --format '{{.store.GraphRoot}}/overlay-images')" >> $GITHUB_OUTPUT
echo "weekstamp=$(date +%YW%W)" >> $GITHUB_OUTPUT
- id: checkout
uses: actions/checkout@v4
- id: corecache
uses: actions/cache@v3
with:
path: |
${{ steps.info.outputs.images-dir }}
${{ github.workflow }}/.golang-cache
${{ github.workflow }}/ui/node_modules
key: "corecache-${{ steps.info.outputs.weekstamp }}-${{ hashFiles('core/ui/yarn.lock', 'core/agent/go.*', 'core/api-server/go.*', 'core/build-image.sh') }}"
- id: build
name: "Build the images"
run: "cd ${REPONAME} && bash build-image.sh"
env:
REPOBASE: ghcr.io/${{needs.module.outputs.owner}}
- id: python-dep
uses: actions/setup-python@v4
with:
python-version: 3.11
- id: push
name: "Push the images"
run: |
git config user.name github-actions
git config user.email [email protected]
pip install semver
# Push the images
trap 'buildah logout ghcr.io' EXIT
buildah login -u ${{ github.actor }} --password-stdin ghcr.io <<<"${{ secrets.GITHUB_TOKEN }}"
for image in ${{ steps.build.outputs.images }} ; do
buildah push $image docker://${image}:${IMAGETAG:?is missing}
if [[ "${image}" != */core || "${{ github.ref_type }}" != "tag" ]]; then
continue # skip non-tag/branch builds
elif python3 -c "import semver, sys; sys.exit(0 if semver.VersionInfo.parse(sys.argv[1]).prerelease else 1)" "${IMAGETAG}" ; then
continue # skip prerelease tags
fi
git tag -f -m "Release ${IMAGETAG:-unknown}" ns8-stable
git push -f origin ns8-stable
buildah push "${image}" "docker://${image}:ns8-stable"
done