Skip to content

Commit

Permalink
isolate publish_dev_image job in another workflow executed only when …
Browse files Browse the repository at this point in the history
…pushed on master
  • Loading branch information
everpeace committed Oct 17, 2022
1 parent cd34b9b commit 6a15c7a
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 40 deletions.
40 changes: 0 additions & 40 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,43 +65,3 @@ jobs:
with:
version: latest
args: release --snapshot --skip-publish --rm-dist --debug

publish_dev_image:
name: Publish Dev Image
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
steps:
- name: Check out
uses: actions/checkout@v3
- name: Set up Go 1.x
uses: actions/setup-go@v3
with:
go-version: ~1.16
id: go
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: pfnet-research
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build Snapshots
uses: goreleaser/goreleaser-action@v3
with:
version: latest
args: release --snapshot --rm-dist --debug
# Mimic docker, docker_manifests artifacts in goreleaser here.
# because "goreleaser release --snapshot" does NOT publish any artifact
- name: Publish Snapshot Images
shell: bash
run: |
set -euo pipefail
IMAGES=($(jq -r '.[] | select(.type=="Docker Image") | .name' dist/artifacts.json))
for i in ${IMAGES[@]}; do
docker push $i
done
MANIFEST=$(jq '.[] | select(.type=="Docker Image") | .name' dist/artifacts.json | jq -sr '.[0]' | sed -e "s|-[a-z0-9]\+$||g")
docker manifest create ${MANIFEST} ${IMAGES[@]}
docker manifest push ${MANIFEST}
MANIFEST_LATEST=$(jq '.[] | select(.type=="Docker Image") | .name' dist/artifacts.json | jq -sr '.[0]' | sed -e "s|:.*$||g"):latest
docker manifest create ${MANIFEST_LATEST} ${IMAGES[@]}
docker manifest push ${MANIFEST_LATEST}
47 changes: 47 additions & 0 deletions .github/workflows/publish_dev_image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Publish Dev Image

on:
push:
branches: [ master ]
tags-ignore: [ "**" ]
paths-ignore: [ "**.md" ]

jobs:
publish_dev_image:
name: Publish Dev Image
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v3
- name: Set up Go 1.x
uses: actions/setup-go@v3
with:
go-version: ~1.16
id: go
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: pfnet-research
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build Snapshots
uses: goreleaser/goreleaser-action@v3
with:
version: latest
args: release --snapshot --rm-dist --debug
# Mimic docker, docker_manifests artifacts in goreleaser here.
# because "goreleaser release --snapshot" does NOT publish any artifact
- name: Publish Snapshot Images
shell: bash
run: |
set -euo pipefail
IMAGES=($(jq -r '.[] | select(.type=="Docker Image") | .name' dist/artifacts.json))
for i in ${IMAGES[@]}; do
docker push $i
done
MANIFEST=$(jq '.[] | select(.type=="Docker Image") | .name' dist/artifacts.json | jq -sr '.[0]' | sed -e "s|-[a-z0-9]\+$||g")
docker manifest create ${MANIFEST} ${IMAGES[@]}
docker manifest push ${MANIFEST}
MANIFEST_LATEST=$(jq '.[] | select(.type=="Docker Image") | .name' dist/artifacts.json | jq -sr '.[0]' | sed -e "s|:.*$||g"):latest
docker manifest create ${MANIFEST_LATEST} ${IMAGES[@]}
docker manifest push ${MANIFEST_LATEST}

0 comments on commit 6a15c7a

Please sign in to comment.