Skip to content

hot-fix: yaml file (#5) #4

hot-fix: yaml file (#5)

hot-fix: yaml file (#5) #4

name: Tag and publish
on:
push:
branches:
- main
jobs:
update_badges:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v3
with:
ref: ${{ env.DEFAULT_BRANCH }}
fetch-depth: 0
token: ${{ secrets.SERVICE_TOKEN }}
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install -e .[dev] --no-cache-dir
- name: Get Python version and Update README.md
run: |
python_version=$(grep "requires-python" pyproject.toml | grep -o ">=[^\"]*")
python_badge=$(grep -o 'python-[^)]*' README.md)
new_python_badge="python-$python_version-blue?logo=python"
sed -i "s/$python_badge/$new_python_badge/g" README.md
- name: Get interrogate values and Update README.md
run: |
interrogate_val=$(interrogate . | grep -o 'actual: [0-9]*\.[0-9]*' | awk '{print $2}')
interrogate_badge=$(grep -o 'interrogate-[^)]*' README.md)
if (( $(echo "$interrogate_val >= 90.00" | bc -l) )); then
new_interrogate_badge="interrogate-$interrogate_val%25-brightgreen"
elif (( $(echo "$interrogate_val < 80.00" | bc -l) )); then
new_interrogate_badge="interrogate-$interrogate_val%25-red"
else
new_interrogate_badge="interrogate-$interrogate_val%25-yellow"
fi
sed -i "s/$interrogate_badge/$new_interrogate_badge/g" README.md
- name: Get Coverage values and Update README.md
run: |
coverage run -m unittest discover
coverage_val=$(coverage report | grep "^TOTAL" | grep -o '[0-9]\+%' | grep -o '[0-9]\+')
coverage_badge=$(grep -o "coverage-[^?]*" README.md)
if (( $(echo "$coverage_val >= 90.00" | bc -l) )); then
new_coverage_badge="coverage-$coverage_val%25-brightgreen"
elif (( $(echo "$coverage_val < 80.00" | bc -l) )); then
new_coverage_badge="coverage-$coverage_val%25-red"
else
new_coverage_badge="coverage-$coverage_val%25-yellow"
fi
sed -i "s/$coverage_badge/$new_coverage_badge/g" README.md
- name: Commit changes
uses: EndBug/add-and-commit@v9
with:
default_author: github_actions
message: "ci: update badges [skip actions]"
add: '["README.md"]'
tag:
needs: update_badges
uses: AllenNeuralDynamics/aind-github-actions/.github/workflows/tag.yml@main
secrets:
SERVICE_TOKEN: ${{ secrets.SERVICE_TOKEN }}
publish:
runs-on: ubuntu-latest
needs: tag
steps:
- uses: actions/checkout@v3
- name: Pull latest changes
run: git pull origin main
- name: Set up Go 1.14
uses: actions/setup-go@v1
with:
go-version: 1.14
id: go
- name: Install Dependencies
run: |
apt-get update && apt-get install -y \
build-essential \
libssl-dev \
uuid-dev \
libgpgme11-dev \
squashfs-tools \
libseccomp-dev \
pkg-config
- name: Install Singularity
env:
SINGULARITY_VERSION: 3.7.0
GOPATH: /tmp/go
run: |
mkdir -p $GOPATH
mkdir -p /usr/local/var/singularity/mnt && \
mkdir -p $GOPATH/src/github.com/sylabs && \
cd $GOPATH/src/github.com/sylabs && \
wget -qO- https://github.com/sylabs/singularity/releases/download/v${SINGULARITY_VERSION}/singularity-ce-${SINGULARITY_VERSION}.tar.gz | \
tar xzv && \
cd singularity-ce-${SINGULARITY_VERSION} && \
./mconfig -p /usr/local && \
make -C builddir && \
make -C builddir install
- name: Build sif container
run: |
mkdir aind-data-transformation/build
singularity build aind-data-transformation/build/container.sif aind-data-transformation/scripts/singularity_build.def
- name: Login and Deploy Container
run: |
echo ${{ secrets.GITHUB_TOKEN }} | singularity remote login -u ${{ github.actor }} --password-stdin oras://ghcr.io
singularity push aind-data-transformation/build/container.sif oras://ghcr.io/${GITHUB_REPOSITORY}:${{ needs.tag.outputs.new_version }}
singularity push aind-data-transformation/build/container.sif oras://ghcr.io/${GITHUB_REPOSITORY}:latest