Skip to content

protected-branches #205

protected-branches

protected-branches #205

name: protected-branches
on:
workflow_dispatch:
push:
branches: [next]
tags: ['v*']
jobs:
integration-tests:
runs-on: imars3d-builder
defaults:
run:
shell: bash -l {0}
steps:
- name: Add pending status
uses: Sibz/github-status-action@v1
if: ${{ github.event_name == 'workflow_dispatch' }}
with:
authToken: ${{secrets.GITHUB_TOKEN}}
context: "Tests with data repository"
description: "pending"
state: "pending"
sha: "${{ github.sha }}"
target_url: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
- uses: actions/checkout@v3
with:
submodules: true
lfs: true
- uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
miniforge-version: latest
environment-file: environment.yml
- name: Tests with data repository
run: python -m pytest -m datarepo
- name: Update job status
uses: Sibz/github-status-action@v1
if: ${{ always() && github.event_name == 'workflow_dispatch' }}
with:
authToken: ${{secrets.GITHUB_TOKEN}}
context: "Tests with data repository"
description: "${{ job.status }}"
state: "${{ job.status }}"
sha: "${{ github.sha }}"
target_url: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
build-conda:
runs-on: ubuntu-latest
needs: [integration-tests]
defaults:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v3
- uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
mamba-version: "*"
environment-file: environment.yml
- name: Build Conda Package
run: |
# boa uses mamba to resolve dependencies
cd conda.recipe
VERSION=$(versioningit ../) conda mambabuild --output-folder . -c conda-forge . || exit 1
conda verify noarch/imars3d*.tar.bz2 || exit 1
- name: Deploy to Anaconda
shell: bash -l {0}
if: startsWith(github.ref, 'refs/tags/v')
env:
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
IS_RC: ${{ contains(github.ref, 'rc') }}
run: |
# label is main or rc depending on the tag-name
CONDA_LABEL="main"
if [ "${IS_RC}" = "true" ]; then CONDA_LABEL="rc"; fi
echo pushing ${{ github.ref }} with label $CONDA_LABEL
anaconda upload --label $CONDA_LABEL conda.recipe/noarch/imars3d*.tar.bz2
trigger-deploy:
runs-on: ubuntu-22.04
needs: [build-conda]
# only trigger deploys from protected branches
if: ${{ github.ref_protected || github.ref_type == 'tag' }}
steps:
- name: Determine Environment
uses: neutrons/branch-mapper@v2
id: conda_env_name
with:
prefix: imars3d
- name: Trigger deploy
id: trigger
uses: eic/trigger-gitlab-ci@v2
with:
url: https://code.ornl.gov
token: ${{ secrets.GITLAB_TRIGGER_TOKEN }}
project_id: 11848
ref_name: main
variables: |
PLAY="update"
CONDA_ENV="${{ steps.conda_env_name.outputs.name }}"
- name: Annotate commit
uses: peter-evans/commit-comment@v2
with:
body: |
GitLab pipeline for ${{ steps.conda_env_name.outputs.name }} has been submitted for this commit: ${{ steps.trigger.outputs.web_url }}