The following if statement is not working.
if: github.ref == 'ref/head/release/*' || contains(github.ref, '/tags/release')
Everything else runs but the if does not. my branch is called release/test It should run when it sees the branch release with anything following that in the. name.
Anyone know why the if statement is not running.
name: Publish
on:
push:
branches:
- main
- release/*
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}-image
TAG_PREXIX: release-v
jobs:
Publish:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: "Bump package version"
id: bumpVersion
uses: "phips28/gh-action-bump-version@master"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PACKAGEJSON_DIR: "./client"
tag-prefix: ${{env.TAG_PREXIX}}
major-wording: "MAJOR,BREAKING CHANGE:"
minor-wording: "feat"
patch-wording: "patch,fix,bugfix,chore"
- name: Log into Container registry
if: github.ref == 'ref/head/release/*' || contains(github.ref, '/tags/release')
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
if: github.ref == 'ref/head/release/*' || contains(github.ref, '/tags/release')
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{env.TAG_PREXIX}}${{steps.bumpVersion.outputs.newTag}}
CodePudding user response:
When you use github.ref == 'ref/head/release/*'
, you ask to Github to match exactly with branch called release/*'
, no manipulation over *
is applied.
If you want to match any branch prefixed with release/
, you need to use the built-in function startsWith
release:
if: startsWith(github.ref, 'ref/head/release/') || contains(github.ref, '/tags/release')
steps: []
See you on the workflow :)