Pārlūkot izejas kodu

ci: Fix ifs for jobs and rename master to main (#1813)

* Reference to branches (heads), not tags, to state the branch condition positively.
* Remove comparison to boolean in the condition for better readability.
* Fix comparison for master/main (use equal operator, startsWith may match too much).
* Update for rename from master to main for the default branch.
Vaclav Petras 3 gadi atpakaļ
vecāks
revīzija
9a2a89379e
1 mainītis faili ar 12 papildinājumiem un 12 dzēšanām
  1. 12 12
      .github/workflows/docker.yml

+ 12 - 12
.github/workflows/docker.yml

@@ -3,13 +3,13 @@
 # Summary
 # Summary
 #
 #
 # job docker-branch-os-matrix:
 # job docker-branch-os-matrix:
-# * creates tags latest-alpine, latest-debian and latest-ubuntu for master branch
+# * creates tags latest-alpine, latest-debian and latest-ubuntu for main branch
 # * creates tags stable-alpine, stable-debian and stable-ubuntu for releasebranch_7_8
 # * creates tags stable-alpine, stable-debian and stable-ubuntu for releasebranch_7_8
 # * if action would trigger other branches as well, they would create
 # * if action would trigger other branches as well, they would create
 #   tags <branch_name>-alpine, <branch_name>-debian and <branch_name>-ubuntu
 #   tags <branch_name>-alpine, <branch_name>-debian and <branch_name>-ubuntu
 #
 #
-# job docker-master-latest:
-# * creates tag latest for master branch
+# job docker-main-latest:
+# * creates tag latest for main branch
 #
 #
 # job docker-release-os-matrix:
 # job docker-release-os-matrix:
 # * creates tags <version>-alpine, <version>-debian and <version>-ubuntu for each release
 # * creates tags <version>-alpine, <version>-debian and <version>-ubuntu for each release
@@ -18,7 +18,7 @@ name: Docker
 
 
 on:
 on:
   push:
   push:
-    branches: [master, releasebranch_7_8]
+    branches: [main, releasebranch_7_8]
     tags: ['*.*.*']
     tags: ['*.*.*']
     paths-ignore: ['doc/**']
     paths-ignore: ['doc/**']
   release:
   release:
@@ -32,13 +32,13 @@ env:
 jobs:
 jobs:
 
 
   # Only run for push to configured branches, do not run for releases.
   # Only run for push to configured branches, do not run for releases.
-  # Take care of different os. For master branch, created tags are:
+  # Take care of different os. For main branch, created tags are:
   # latest-alpine, latest-debian, latest-ubuntu
   # latest-alpine, latest-debian, latest-ubuntu
   # For releasebranch_7_8, created tags are:
   # For releasebranch_7_8, created tags are:
   # stable-alpine, stable-debian, stable-ubuntu
   # stable-alpine, stable-debian, stable-ubuntu
   docker-branch-os-matrix:
   docker-branch-os-matrix:
     name: build and push ${{ matrix.os }} for branch
     name: build and push ${{ matrix.os }} for branch
-    if: startsWith(github.ref, 'refs/tags/') != true
+    if: startsWith(github.ref, 'refs/heads/')
     runs-on: ubuntu-latest
     runs-on: ubuntu-latest
 
 
     strategy:
     strategy:
@@ -57,7 +57,7 @@ jobs:
       - id: meta
       - id: meta
         name: Create tag name
         name: Create tag name
         run: |
         run: |
-          if [ "$GITHUB_REF" == "refs/heads/master" ]
+          if [ "$GITHUB_REF" == "refs/heads/main" ]
           then
           then
             TAG_PREFIX=latest
             TAG_PREFIX=latest
           elif [ "$GITHUB_REF" == "refs/heads/releasebranch_7_8" ]
           elif [ "$GITHUB_REF" == "refs/heads/releasebranch_7_8" ]
@@ -94,13 +94,13 @@ jobs:
         run: echo ${{ steps.docker_build.outputs.digest }}
         run: echo ${{ steps.docker_build.outputs.digest }}
 
 
 
 
-  # Only run for push to master branch
+  # Only run for push to main branch
   # Take care of tag latest
   # Take care of tag latest
   # This job needs to build the configured image (ubuntu)
   # This job needs to build the configured image (ubuntu)
-  # again for master branch to create latest tag.
-  docker-master-latest:
-    name: build and push latest for master branch
-    if: startsWith(github.ref, 'refs/heads/master')
+  # again for main branch to create latest tag.
+  docker-main-latest:
+    name: build and push latest for main branch
+    if: github.ref == 'refs/heads/main'
     runs-on: ubuntu-latest
     runs-on: ubuntu-latest
 
 
     steps:
     steps: