Use githubs runners #3
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
# https://www.truenas.com/software-status/ | |
name: CI | |
on: | |
push: | |
tags: | |
- "v*" | |
branches: | |
- master | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
cancel-previous-runs: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Cancel Previous Runs | |
uses: styfle/cancel-workflow-action@0.11.0 | |
with: | |
access_token: ${{ github.token }} | |
build-npm-linux-amd64: | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
- shell: bash | |
name: npm install | |
run: | | |
ci/bin/build.sh | |
- name: upload build | |
uses: actions/upload-artifact@v3 | |
with: | |
name: node-modules-linux-amd64 | |
path: node_modules-linux-amd64.tar.gz | |
retention-days: 1 | |
# zfs-local drivers | |
csi-sanity-zfs-local: | |
needs: | |
- build-npm-linux-amd64 | |
strategy: | |
fail-fast: false | |
matrix: | |
config: | |
- zfs-local/zvol.yaml | |
- zfs-local/dataset.yaml | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/download-artifact@v3 | |
with: | |
name: node-modules-linux-amd64 | |
- name: csi-sanity | |
run: | | |
# run tests | |
ci/bin/run.sh | |
env: | |
TEMPLATE_CONFIG_FILE: "./ci/configs/${{ matrix.config }}" | |
# local-hostpath driver | |
csi-sanity-local-hostpath: | |
needs: | |
- build-npm-linux-amd64 | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [Linux, Windows] | |
include: | |
- os: Linux | |
npmartifact: node-modules-linux-amd64 | |
template: "./ci/configs/local-hostpath/basic.yaml" | |
run: | | |
# run tests | |
ci/bin/run.sh | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/download-artifact@v3 | |
with: | |
name: ${{ matrix.npmartifact }} | |
- name: csi-sanity | |
run: ${{ matrix.run }} | |
env: | |
TEMPLATE_CONFIG_FILE: "${{ matrix.template }}" | |
CSI_SANITY_SKIP: "should fail when requesting to create a snapshot with already existing name and different source volume ID|should fail when requesting to create a volume with already existing name and different capacity" | |
determine-image-tag: | |
runs-on: ubuntu-latest | |
outputs: | |
tag: ${{ steps.tag.outputs.tag }} | |
steps: | |
- id: tag | |
run: | | |
if [[ $GITHUB_REF == refs/tags/* ]]; then | |
export GIT_TAG=${GITHUB_REF#refs/tags/} | |
else | |
export GIT_BRANCH=${GITHUB_REF#refs/heads/} | |
fi | |
if [[ -n "${GIT_TAG}" ]]; then | |
echo "::set-output name=tag::${GIT_TAG}" | |
elif [[ -n "${GIT_BRANCH}" ]]; then | |
if [[ "${GIT_BRANCH}" == "master" ]]; then | |
echo "::set-output name=tag::latest" | |
else | |
echo "::set-output name=tag::${GIT_BRANCH}" | |
fi | |
else | |
: | |
fi | |
build-and-push-image: | |
runs-on: ubuntu-latest | |
needs: | |
- determine-image-tag | |
- csi-sanity-zfs-local | |
- csi-sanity-local-hostpath | |
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job. | |
permissions: | |
contents: read | |
packages: write | |
# | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here. | |
- name: Log in to the Container registry | |
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels. | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
# This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages. | |
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository. | |
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step. | |
- name: Build and push Docker image | |
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 | |
with: | |
context: . | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} |