Using event.release.target_commitish for target branch #284
Workflow file for this run
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
name: docker image | |
on: | |
push: | |
branches: [ master, gis-based-mode-detection, cleanup-cicd ] | |
# tags: | |
# - "v[0-9]+.[0-9]+.[0-9]+" | |
release: | |
types: [published] | |
#Dockerhub credentials are set as environment variables | |
env: | |
DOCKER_USER: ${{secrets.DOCKER_USER}} | |
DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}} | |
jobs: | |
dump_contexts_to_log: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Dump GitHub context | |
env: | |
GITHUB_CONTEXT: ${{ toJson(github) }} | |
run: echo "$GITHUB_CONTEXT" | |
- name: Dump job context | |
env: | |
JOB_CONTEXT: ${{ toJson(job) }} | |
run: echo "$JOB_CONTEXT" | |
- name: Dump steps context | |
env: | |
STEPS_CONTEXT: ${{ toJson(steps) }} | |
run: echo "$STEPS_CONTEXT" | |
- name: Dump runner context | |
env: | |
RUNNER_CONTEXT: ${{ toJson(runner) }} | |
run: echo "$RUNNER_CONTEXT" | |
- name: Dump strategy context | |
env: | |
STRATEGY_CONTEXT: ${{ toJson(strategy) }} | |
run: echo "$STRATEGY_CONTEXT" | |
- name: Dump matrix context | |
env: | |
MATRIX_CONTEXT: ${{ toJson(matrix) }} | |
run: echo "$MATRIX_CONTEXT" | |
debug-info: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Print commit info | |
run: | | |
echo "Commit message: ${{ github.event.head_commit.message }}" | |
echo "Head commit author: ${{ github.event.head_commit.author.name }}" | |
echo "Event name: ${{ github.event_name }}" | |
echo "Actor: ${{ github.actor }}" | |
echo "Ref: ${{ github.ref }}" | |
echo "Ref name: ${{ github.ref_name }}" | |
echo "Ref type: ${{ github.ref_type }}" | |
echo "Default branch: ${{ github.event.repository.default_branch }}" | |
echo "Github event base ref: ${{ github.event.base_ref }}" | |
test-with-docker: | |
uses: MukuFlash03/e-mission-server/.github/workflows/test-with-docker.yml@cleanup-cicd | |
test-with-manual-install: | |
uses: MukuFlash03/e-mission-server/.github/workflows/test-with-manual-install.yml@cleanup-cicd | |
get-branch-name: | |
runs-on: ubuntu-latest | |
outputs: | |
branch_name: ${{ steps.get-branch-name.outputs.branch_name }} | |
steps: | |
- name: Get branch name based on ref_type | |
id: get-branch-name | |
run: | | |
if [ "${{ github.ref_type }}" == "tag" ]; then | |
# base_ref=${{ github.event.base_ref }} | |
# echo "Branch name: branch_name=${base_ref#refs/heads/}" | |
# echo "branch_name=${base_ref#refs/heads/}" >> "$GITHUB_OUTPUT" | |
target_branch=${{ github.event.release.target_commitish }} | |
echo "branch_name=${target_branch}" >> "$GITHUB_OUTPUT" | |
elif [ "${{ github.ref_type }}" == "branch" ]; then | |
echo "branch_name=${GITHUB_REF##*/}" >> "$GITHUB_OUTPUT" | |
fi | |
build: | |
# if: ${{ !contains(github.event.head_commit.author.name, 'Github Actions bot to update .env with latest tags') && github.ref_type == 'tag' }} | |
if: ${{ !contains(github.event.head_commit.author.name, 'Github Actions bot to update .env with latest tags') }} | |
needs: [test-with-docker, test-with-manual-install, get-branch-name] | |
uses: MukuFlash03/e-mission-server/.github/workflows/reusable_image_build_push.yml@cleanup-cicd | |
with: | |
repo: ${{ github.event.repository.name }} | |
branch: ${{ needs.get-branch-name.outputs.branch_name }} | |
secrets: inherit | |
dispatch: | |
if: ${{ github.ref_type == 'tag' }} | |
needs: [build] | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
include: | |
- repo: MukuFlash03/nrel-openpath-join-page | |
branch: cleanup-cicd | |
- repo: MukuFlash03/op-admin-dashboard | |
branch: cleanup-cicd | |
- repo: MukuFlash03/em-public-dashboard | |
branch: cleanup-cicd | |
# - repo: e-mission/op-admin-dashboard | |
# branch: master | |
# - repo: e-mission/em-public-dashboard | |
# branch: main | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Trigger workflow in admin-dash, public-dash | |
run: | | |
curl -L \ | |
-X POST \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Authorization: Bearer ${{ secrets.GH_FG_PAT_TAGS }}" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
https://api.github.com/repos/${{ matrix.repo }}/actions/workflows/image_build_push.yml/dispatches \ | |
-d '{"ref":"${{ matrix.branch }}"}' |