Skip to content

Update workflows to gh-actions v2 #45

Update workflows to gh-actions v2

Update workflows to gh-actions v2 #45

Workflow file for this run

name: Tests, Package, and Deployment
on:
workflow_dispatch:
pull_request:
push:
branches: [next, qa, main]
tags: ["v*"]
env:
PKG_NAME: dgs_resolution
MODULE_NAME: dgs_resolution
# cancel previous job if new commit is pushed
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
build:
name: Build conda package
runs-on: ubuntu-latest
permissions:
contents: read # for actions/checkout
security-events: write # for github/codeql-action/upload-sarif to upload Grype results
defaults:
run:
shell: bash -el {0}
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0
fetch-tags: true
ref: ${{ github.ref }}
- name: Setup pixi
uses: prefix-dev/setup-pixi@a09b6247153796b190642a2b53fac4241043cf6f # v0.10.0
- name: Build conda package
run: |
pixi run conda-build
# Copy conda package to workspace root so it can be uploaded as an artifact.
find local-channel -name "*.conda" -exec cp {} . \;
# pkg-verify requires a conda env that already has the package
# installed (and micromamba on PATH); pkg-install sets both up.
- name: Install built conda package
id: install
uses: neutrons/gh-actions/pkg-install@eb7a7c6fcfd0cda1a7b238329afc0afd09a4f4af # v2
with:
package-name: ${{ env.PKG_NAME }}
local-channel: ./local-channel
python-version: "3.11"
extra-channels: neutrons
- name: Verify conda package
uses: neutrons/gh-actions/pkg-verify@eb7a7c6fcfd0cda1a7b238329afc0afd09a4f4af # v2
with:
package-name: ${{ env.PKG_NAME }}
conda-env-name: ${{ steps.install.outputs.conda_env }}
local-channel: ./local-channel
# Audit the dependencies of the conda package we just installed. SARIF
# results are uploaded to GitHub code scanning by the grype action.
- name: Scan installed environment with Grype
uses: neutrons/gh-actions/grype@eb7a7c6fcfd0cda1a7b238329afc0afd09a4f4af # v2
with:
path: ${{ steps.install.outputs.conda_install_dir }}
- name: Upload conda package as artifact
uses: actions/upload-artifact@v7
with:
name: artifact-conda-package
path: ${{ env.PKG_NAME }}-*.conda
publish:
name: Upload package to anaconda
runs-on: ubuntu-latest
needs: [build]
if: startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/next'
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0
fetch-tags: true
- name: Setup Pixi
uses: prefix-dev/setup-pixi@a09b6247153796b190642a2b53fac4241043cf6f # v0.10.0
- name: Download conda package artifact
uses: actions/download-artifact@v8
with:
name: artifact-conda-package
- name: Upload package to anaconda
uses: neutrons/gh-actions/publish@eb7a7c6fcfd0cda1a7b238329afc0afd09a4f4af # v2
with:
anaconda-token: ${{ secrets.ANACONDA_TOKEN }}
organization: neutrons
package-path: ${{ env.PKG_NAME }}-*.conda
- name: Remove old packages
if: github.ref == 'refs/heads/next'
uses: neutrons/gh-actions/pkg-remove@eb7a7c6fcfd0cda1a7b238329afc0afd09a4f4af # v2
with:
anaconda-token: ${{ secrets.ANACONDA_TOKEN }}
organization: neutrons
package-name: ${{ env.PKG_NAME }}
label: ${{ env.CONDA_LABEL }}
keep: 5
# Trigger GitLab dev deploy pipeline
deploy-dev:
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/next'
steps:
- name: Get Environment Name
uses: neutrons/branch-mapper@main
id: env_name
with:
prefix: ${{ env.PKG_NAME }}
- name: Trigger Dev Deploy
uses: eic/trigger-gitlab-ci@v3.3
id: trigger
with:
url: https://code.ornl.gov
project_id: 20651
ref_name: main
token: ${{ secrets.GITLAB_DEPLOY_TOKEN }}
- name: Annotate commit
uses: peter-evans/commit-comment@v4
with:
body: |
GitLab pipeline for ${{ steps.env_name.outputs.name }} has been submitted for this commit: ${{ steps.trigger.outputs.web_url }}