Skip to content

Commit

Permalink
ci: build docker only when secrets are present
Browse files Browse the repository at this point in the history
Fix: use direct comparison instead of strings.Contains to filter layernames

chore: fix inaccessible secrets

chore: fix invalid mapping
  • Loading branch information
iwpnd committed Jul 3, 2024
1 parent c5bb076 commit aa8e390
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/on_release_publish.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
name: On release publish
on:
push:
pull_request:
push:
branches:
- master
release:
types: [published]

jobs:

gen_version:
name: Generate software version
runs-on: ubuntu-22.04
Expand Down Expand Up @@ -223,6 +224,8 @@ jobs:
needs: [gen_version,build_ui]
runs-on: ubuntu-22.04
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
DOCKERHUB_ORG: gospatial
DOCKERHUB_REPO: tegola
BUILD_ARGS: |
Expand All @@ -243,6 +246,7 @@ jobs:

- name: Login to Docker Hub
uses: docker/login-action@v3
if: env.DOCKERHUB_USERNAME != '' && env.DOCKERHUB_TOKEN != ''
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
Expand All @@ -259,6 +263,7 @@ jobs:
# we are not rebuilding linux/amd64
- name: Build docker image for testing
uses: docker/build-push-action@v5
if: env.DOCKERHUB_USERNAME != '' && env.DOCKERHUB_TOKEN != ''
with:
context: .
load: true
Expand All @@ -267,6 +272,7 @@ jobs:
tags: ${{ env.DOCKERHUB_ORG }}/${{ env.DOCKERHUB_REPO }}:${{ env.VERSION }}

- name: Test image build
if: env.DOCKERHUB_USERNAME != '' && env.DOCKERHUB_TOKEN != ''
run: |
docker run --rm ${DOCKERHUB_ORG}/${DOCKERHUB_REPO}:${VERSION} version
Expand Down
2 changes: 1 addition & 1 deletion atlas/map.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func (m Map) FilterLayersByName(names ...string) Map {
nameStr := strings.Join(names, ",")
for i := range m.Layers {
// if we have a name set, use it for the lookup
if m.Layers[i].Name != "" && strings.Contains(nameStr, m.Layers[i].Name) {
if m.Layers[i].Name != "" && nameStr == m.Layers[i].Name {
layers = append(layers, m.Layers[i])
continue
} else if m.Layers[i].ProviderLayerName != "" && strings.Contains(nameStr, m.Layers[i].ProviderLayerName) { // default to using the ProviderLayerName for the lookup
Expand Down
20 changes: 20 additions & 0 deletions atlas/map_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,26 @@ func TestMapFilterLayersByName(t *testing.T) {
},
},
},
{
grid: atlas.Map{
Layers: []atlas.Layer{
{
Name: "layer1",
},
{
Name: "layer1roads",
},
},
},
name: "layer1roads",
expected: atlas.Map{
Layers: []atlas.Layer{
{
Name: "layer1roads",
},
},
},
},
}

for i, tc := range testcases {
Expand Down

0 comments on commit aa8e390

Please sign in to comment.