Skip to content

action test - sh fix #24

action test - sh fix

action test - sh fix #24

Workflow file for this run

name: Generate CV file
on:
push:
branches:
- lesfII
- main
# act -s GITHUB_TOKEN="$(gh auth token)" --container-architecture linux/amd64 -vact -s GITHUB_TOKEN="$(gh auth token)" --container-architecture linux/amd64 -v
# act -s GITHUB_TOKEN="$(gh auth token)" --container-architecture linux/amd64 -b -W .github/workflows/gen_CV.yml
# docker exec -it act-Generate-CV-file-create-branch-and-update-files-cabe81e196626eaf2f1a205b6f6f95341b0aa587d4d7127baba6ccfa7bef525a /bin/bash
jobs:
create-branch-and-update-files:
runs-on: ubuntu-latest
permissions:
actions: write
checks: write
contents: write
deployments: write
id-token: write
issues: write
discussions: write
packages: write
pages: write
pull-requests: write
repository-projects: write
security-events: write
statuses: write
steps:
- name: Check out the repository
uses: actions/checkout@v2
# - name: Install NPM
# uses: actions/setup-node@v3
- name: Set up Git
run: |
git config user.email "[email protected]"
git config user.name "CMIP-IPO: Automated GitHub Action"
git config credential.helper store
git config --global user.email "[email protected]"
git config --global user.name "CMIP-IPO GitHub Action"
git config --global push.default current
GH_TOKEN=${{ secrets.GITHUB_TOKEN }}
echo "GH_TOKEN=${GH_TOKEN}" >> $GITHUB_ENV
echo "GITHUB_TOKEN=${GH_TOKEN}" >> $GITHUB_ENV
shell: bash
- name: Set GIT repo environment variables
run: |
echo "COMMIT_HASH=${GITHUB_SHA}" >> $GITHUB_ENV
echo "TAG_VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
# Use GitHub API to get commit information
COMMIT_DATE=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \
"https://api.github.com/repos/${{ github.repository }}/commits/${{ github.sha }}" | \
jq -r '.commit.author.date')
echo "COMMIT_DATE=${COMMIT_DATE}" >> $GITHUB_ENV
shell: bash
- name: Display GIT environment variables
run: |
echo "Commit Hash: $COMMIT_HASH"
echo "Tag Version: $TAG_VERSION"
echo "Commit Date: $COMMIT_DATE"
- name: Clear previous
run: |
if [ -z "$ACT" ]; then
echo "Branch: $(git rev-parse --abbrev-ref HEAD)"
if [ -e "CVs/CMIP6Plus_CV.json" ]; then
echo "Removing output CMIP6Plus_CV.json"
rm -f CVs/CMIP6Plus_CV.json
git add -A
git commit -m 'Remove CMIP6Plus_CV.json'
git push origin $(git rev-parse --abbrev-ref HEAD)
else
mkdir -p CVs
fi
else
echo "Skipping this step in 'act' environment."
fi
shell: bash
- name: Print latest commit SHA
id: commit_sha
run: |
commit='ds'
echo "COMMITS='hello'" >> $GITHUB_ENV
echo "COMMITS=hello" >> $GITHUB_OUTPUT
echo "$(git rev-parse HEAD)"
echo "commit=$(git rev-parse HEAD)" >> $GITHUB_ENV
shell: bash
- name: Get latest tag for current branch
id: repo_tag
run: |
echo "$(git describe --tags --abbrev=0)"
shell: bash
- name: Get latest commit date
id: latest_commit
run: |
echo "$(git log -1 --format='%at' | xargs -I{} date -r {} '+%Y/%m/%d_%H:%M:%S')"
shell: bash
# envvar steps.latest_commit.outputs.commit_date
# stdout steps.latest_commit.outputs.stdout
# echo "COMMITS=hello" >> $GITHUB_OUTPUT
# echo "${{git rev-parse HEAD}}i"
# echo "commit=${{git rev-parse HEAD}}" >> $GITHUB_ENV"
- name: Use the information in subsequent steps or jobs
run: |
echo "Using commit SHA: ${{ steps.commit_sha.outputs.stdout }}"
echo "Using latest tag: ${{ steps.repo_tag.outputs.stdout }}"
echo "Using latest commit date: ${{ steps.latest_commit.outputs.stdout }}"
shell: bash
- name: Run Python Check
id: 'run-python-script'
run: python create_cv.py -c "${COMMIT_HASH}" -t "${TAG_VERSION}" -d "${COMMIT_DATE}"
working-directory: .github/workflows/libs
env:
PYTHON_SCRIPT_OUTPUT: ${{ steps.run-python-script.outputs.stdout }}
PYTHON_SCRIPT_ERROR: ${{ steps.run-python-script.outputs.stderr }}
continue-on-error: false
# - name: Print output
# run: |
# echo "::set-output name=PYSTD::$PYTHON_SCRIPT_OUTPUT"
# echo "::set-output name=PYERR::$PYTHON_SCRIPT_ERROR"
# - name: Check Python script output
# run: |
# echo "Python script output: $PYTHON_SCRIPT_OUTPUT"
# if [[ "$PYTHON_SCRIPT_OUTPUT" == "FAILED"* ]]; then
# echo "Issue processing failed. Closing the issue..."
# gh issue close "${{ github.event.issue.number }}"
# gh issue comment "${{ github.event.issue.number }}" --body "Processing failed with the following error: $PYTHON_SCRIPT_OUTPUT"
# else
# echo "Issue processed successfully."
# fi
# shell: bash
- name: Write new CV
run: |
if [ -z "$ACT" ]; then
echo "Branch: $(git rev-parse --abbrev-ref HEAD)"
if [ -e "CVs/CMIP6Plus_CV.json" ]; then
current_datetime=$(date +"%Y-%m-%d %H:%M")
git add -A
git add -f CVs/CMIP6Plus_CV.json
git commit -m "Automatically generated CV.json: $current_datetime"
git push origin $(git rev-parse --abbrev-ref HEAD)
fi
else
echo "Skipping this step in 'act' environment."
fi
shell: bash
# - name: Install fx
# run: |
# if [ -n "$ACT" ]; then
# sudo npm install -g fx
# fi
# shell: bash
- name: Debug current working directory
run: |
pwd
ls -al
- name: View JSON file with jq
run: |
if [ -n "$ACT" ]; then
# fx -y < CVs/CMIP6Plus_CV.json
# jq '.' CVs/CMIP6Plus_CV.json
echo "jghjgh $(steps.commit_sha.outputs.COMMITS) ${COMMITS} kl"
fi
shell: bash
- name: If using act detach -b for debugging
run: |
if [ -n "$ACT" ]; then
echo "Delaying by 360 seconds for testing with act"
sleep 360
fi