workflows
This commit is contained in:
parent
c1b6b91404
commit
80bd89e5eb
3 changed files with 56 additions and 57 deletions
71
.github/workflows/check_changes.yml
vendored
71
.github/workflows/check_changes.yml
vendored
|
@ -5,74 +5,73 @@ on:
|
||||||
# 07:00 UTC each day
|
# 07:00 UTC each day
|
||||||
- cron: '0 7 * * *'
|
- cron: '0 7 * * *'
|
||||||
|
|
||||||
release:
|
push:
|
||||||
types: [published]
|
tags: ['*']
|
||||||
|
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
get_releases:
|
get_tags:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
releases: ${{ steps.get.outputs.result }}
|
tags: ${{ steps.get.outputs.result }}
|
||||||
empty_releases: ${{ steps.check.outputs.result }}
|
empty_tags: ${{ steps.check.outputs.result }}
|
||||||
steps:
|
steps:
|
||||||
- name: Docker target releases
|
- name: Docker target tags
|
||||||
id: fetch_target_releases
|
id: fetch_target_tags
|
||||||
uses: mxpicture/action-docker-hub-fetch-releases@v1
|
uses: mxpicture/action-docker-hub-fetch-tags@v1
|
||||||
with:
|
with:
|
||||||
repository: mxpicture/openwrt-rootfs
|
repository: mxpicture/openwrt-rootfs
|
||||||
max_items: "999999"
|
max_items: "999999"
|
||||||
|
|
||||||
- name: Docker source releases
|
- name: Docker source tags
|
||||||
id: fetch_source_releases
|
id: fetch_source_tags
|
||||||
uses: mxpicture/action-docker-hub-fetch-releases@v1
|
uses: mxpicture/action-docker-hub-fetch-tags@v1
|
||||||
with:
|
with:
|
||||||
repository: openwrtorg/rootfs
|
repository: openwrtorg/rootfs
|
||||||
max_items: "999999"
|
max_items: "999999"
|
||||||
|
|
||||||
- name: Get releases, compare docker hub image dates
|
- name: Get tags, compare docker hub image dates
|
||||||
uses: actions/github-script@v5
|
uses: actions/github-script@v5
|
||||||
id: get
|
id: get
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
const releases = (await github.request("https://api.github.com/repos/"
|
const tags = (await github.request("https://api.github.com/repos/"
|
||||||
+ context.repo.owner + "/" + context.repo.repo + "/releases")).data
|
+ context.repo.owner + "/" + context.repo.repo + "/tags")).data
|
||||||
const target_releases = ${{ steps.fetch_target_releases.outputs.results }}
|
const target_tags = ${{ steps.fetch_target_tags.outputs.results }}
|
||||||
const source_releases = ${{ steps.fetch_source_releases.outputs.results }}
|
const source_tags = ${{ steps.fetch_source_tags.outputs.results }}
|
||||||
let output = []
|
let output = []
|
||||||
for (const release of releases) {
|
for (const tag of tags) {
|
||||||
console.log("Processing release: " + release.tag_name)
|
console.log("Processing tag: " + tag.name)
|
||||||
for (const source_release of source_releases) {
|
for (const source_tag of source_tags) {
|
||||||
if ( source_release.tag_name === release.tag_name ) {
|
if ( source_tag.name === tag.name ) {
|
||||||
let found = false
|
let found = false
|
||||||
for (const target_release of target_releases) {
|
for (const target_tag of target_tags) {
|
||||||
if ( source_release.tag_name === target_release.tag_name ) {
|
if ( source_tag.name === target_tag.name ) {
|
||||||
found = true
|
found = true
|
||||||
console.log("Last updated (source): " + source_release.last_updated)
|
console.log("Last updated (source): " + source_tag.last_updated)
|
||||||
console.log("Last updated (target): " + target_release.last_updated)
|
console.log("Last updated (target): " + target_tag.last_updated)
|
||||||
if ( source_release.last_updated > target_release.last_updated ) {
|
if ( source_tag.last_updated > target_tag.last_updated ) {
|
||||||
console.log("Trigger event for release: " + release.tag_name)
|
console.log("Trigger event for tag: " + tag.name)
|
||||||
output.push({ "name": release.tag_name })
|
output.push({ "name": tag.name })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (found != true) {
|
if (found != true) {
|
||||||
console.log("Trigger event for release: " + release.tag_name)
|
console.log("Trigger event for tag: " + tag.name)
|
||||||
output.push({ "name": release.tag_name })
|
output.push({ "name": tag.name })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return output
|
return output
|
||||||
|
- name: Check tags empty
|
||||||
- name: Check releases empty
|
|
||||||
uses: actions/github-script@v5
|
uses: actions/github-script@v5
|
||||||
id: check
|
id: check
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
let output = ${{ steps.get.outputs.result }}
|
let output = ${{ steps.get.outputs.result }}
|
||||||
console.log("Count releases: " + (output.length))
|
console.log("Count tags: " + (output.length))
|
||||||
|
|
||||||
if (output.length == 0) {
|
if (output.length == 0) {
|
||||||
console.log("empty")
|
console.log("empty")
|
||||||
|
@ -82,12 +81,12 @@ jobs:
|
||||||
return 'false'
|
return 'false'
|
||||||
}
|
}
|
||||||
dispatch:
|
dispatch:
|
||||||
needs: get_releases
|
needs: get_tags
|
||||||
if: ${{ fromJSON(needs.get_releases.outputs.empty_releases) == 'false' }}
|
if: ${{ fromJSON(needs.get_tags.outputs.empty_tags) == 'false' }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
release: ${{ fromJSON(needs.get_releases.outputs.releases) }}
|
tag: ${{ fromJSON(needs.get_tags.outputs.tags) }}
|
||||||
steps:
|
steps:
|
||||||
- name: Dispatch deploy
|
- name: Dispatch deploy
|
||||||
uses: peter-evans/repository-dispatch@v1
|
uses: peter-evans/repository-dispatch@v1
|
||||||
|
@ -95,4 +94,4 @@ jobs:
|
||||||
token: ${{ secrets.ACCESS_TOKEN }}
|
token: ${{ secrets.ACCESS_TOKEN }}
|
||||||
repository: ${{ github.repository }}
|
repository: ${{ github.repository }}
|
||||||
event-type: docker_hub
|
event-type: docker_hub
|
||||||
client-payload: '{"release": "${{ matrix.release.tag_name }}"}'
|
client-payload: '{"tag": "${{ matrix.tag.name }}"}'
|
14
.github/workflows/docker_hub.yml
vendored
14
.github/workflows/docker_hub.yml
vendored
|
@ -18,11 +18,11 @@ jobs:
|
||||||
username: mxpicture
|
username: mxpicture
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Extract release name
|
- name: Extract tag name
|
||||||
shell: bash
|
shell: bash
|
||||||
run: echo "##[set-output name=release;]$(echo ${GITHUB_REF#refs/*/})"
|
run: echo "##[set-output name=tag;]$(echo ${GITHUB_REF#refs/*/})"
|
||||||
if: github.event_name != 'repository_dispatch'
|
if: github.event_name != 'repository_dispatch'
|
||||||
id: extract_release
|
id: extract_tag
|
||||||
|
|
||||||
- name: Build and push (on push)
|
- name: Build and push (on push)
|
||||||
id: docker_build_push
|
id: docker_build_push
|
||||||
|
@ -30,8 +30,8 @@ jobs:
|
||||||
if: github.event_name != 'repository_dispatch'
|
if: github.event_name != 'repository_dispatch'
|
||||||
with:
|
with:
|
||||||
push: true
|
push: true
|
||||||
releases: mxpicture/netbox:${{ steps.extract_release.outputs.release }}
|
tags: mxpicture/netbox:${{ steps.extract_tag.outputs.tag }}
|
||||||
build-args: "BASE_IMAGE_VERSION=${{ steps.extract_release.outputs.release }}"
|
build-args: "BASE_IMAGE_VERSION=${{ steps.extract_tag.outputs.tag }}"
|
||||||
|
|
||||||
- name: Build and push (on dispatch)
|
- name: Build and push (on dispatch)
|
||||||
id: docker_build_dispatch
|
id: docker_build_dispatch
|
||||||
|
@ -39,5 +39,5 @@ jobs:
|
||||||
if: github.event_name == 'repository_dispatch'
|
if: github.event_name == 'repository_dispatch'
|
||||||
with:
|
with:
|
||||||
push: true
|
push: true
|
||||||
releases: mxpicture/netbox:${{ github.event.client_payload.release }}
|
tags: mxpicture/netbox:${{ github.event.client_payload.tag }}
|
||||||
build-args: "BASE_IMAGE_VERSION=${{ github.event.client_payload.release }}"
|
build-args: "BASE_IMAGE_VERSION=${{ github.event.client_payload.tag }}"
|
28
.github/workflows/docker_hub_force_all.yml
vendored
28
.github/workflows/docker_hub_force_all.yml
vendored
|
@ -4,33 +4,33 @@ on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
get_releases:
|
get_tags:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
releases: ${{ steps.get.outputs.result }}
|
tags: ${{ steps.get.outputs.result }}
|
||||||
empty_releases: ${{ steps.check.outputs.result }}
|
empty_tags: ${{ steps.check.outputs.result }}
|
||||||
steps:
|
steps:
|
||||||
- name: Get releases
|
- name: Get tags
|
||||||
uses: actions/github-script@v5
|
uses: actions/github-script@v5
|
||||||
id: get
|
id: get
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
const releases = (await github.request("https://api.github.com/repos/"
|
const tags = (await github.request("https://api.github.com/repos/"
|
||||||
+ context.repo.owner + "/" + context.repo.repo + "/releases")).data
|
+ context.repo.owner + "/" + context.repo.repo + "/tags")).data
|
||||||
|
|
||||||
let output = []
|
let output = []
|
||||||
|
|
||||||
for(let i=0; i<releases.length; i++) {
|
for(let i=0; i<tags.length; i++) {
|
||||||
output.push({ "name": releases[i].tag_name })
|
output.push({ "name": tags[i].name })
|
||||||
}
|
}
|
||||||
return output
|
return output
|
||||||
- name: Check releases empty
|
- name: Check tags empty
|
||||||
uses: actions/github-script@v5
|
uses: actions/github-script@v5
|
||||||
id: check
|
id: check
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
let output = ${{ steps.get.outputs.result }}
|
let output = ${{ steps.get.outputs.result }}
|
||||||
console.log("Count releases: " + (output.length))
|
console.log("Count tags: " + (output.length))
|
||||||
|
|
||||||
if (output.length == 0) {
|
if (output.length == 0) {
|
||||||
console.log("empty")
|
console.log("empty")
|
||||||
|
@ -40,12 +40,12 @@ jobs:
|
||||||
return 'false'
|
return 'false'
|
||||||
}
|
}
|
||||||
dispatch:
|
dispatch:
|
||||||
needs: get_releases
|
needs: get_tags
|
||||||
if: ${{ fromJSON(needs.get_releases.outputs.empty_releases) == 'false' }}
|
if: ${{ fromJSON(needs.get_tags.outputs.empty_tags) == 'false' }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
release: ${{ fromJSON(needs.get_releases.outputs.releases) }}
|
tag: ${{ fromJSON(needs.get_tags.outputs.tags) }}
|
||||||
steps:
|
steps:
|
||||||
- name: Dispatch deploy
|
- name: Dispatch deploy
|
||||||
uses: peter-evans/repository-dispatch@v1
|
uses: peter-evans/repository-dispatch@v1
|
||||||
|
@ -53,4 +53,4 @@ jobs:
|
||||||
token: ${{ secrets.ACCESS_TOKEN }}
|
token: ${{ secrets.ACCESS_TOKEN }}
|
||||||
repository: ${{ github.repository }}
|
repository: ${{ github.repository }}
|
||||||
event-type: docker_hub
|
event-type: docker_hub
|
||||||
client-payload: '{"release": "${{ matrix.release.name }}"}'
|
client-payload: '{"tag": "${{ matrix.tag.name }}"}'
|
Loading…
Add table
Add a link
Reference in a new issue