Skip to content

Commit

Permalink
Fix deprecated GHA
Browse files Browse the repository at this point in the history
Updates set-output to use env-vars
Upgrades Docker actions
Upgrades upload-assets
Updates to Go 1.19

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
  • Loading branch information
alexellis committed Jan 24, 2023
1 parent 6cc975b commit 9ca5a78
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 46 deletions.
33 changes: 13 additions & 20 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name:
name: build

on:
push:
Expand All @@ -10,45 +10,38 @@ on:

jobs:
build:
strategy:
matrix:
go-version: [ 1.18.x ]
os: [ ubuntu-latest ]
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
with:
fetch-depth: 1
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
go-version: 1.19.x
- name: Make all
run: make all

- name: Get TAG
id: get_tag
run: echo TAG=${GITHUB_REF#refs/tags/} >> $GITHUB_ENV

- name: Get Repo Owner
id: get_repo_owner
run: >
echo ::set-output name=repo_owner::$(echo ${{ github.repository_owner }} |
tr '[:upper:]' '[:lower:]')
- name: Get Repo Name
id: get_repo_name
run: >
echo ::set-output name=repo_name::$(echo ${{ github.repository }} |
tr '[:upper:]' '[:lower:]' |
awk -F'/' '{print $2}')
run: echo "REPO_OWNER=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" > $GITHUB_ENV

- name: Set up QEMU
uses: docker/setup-qemu-action@v1
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v2

- name: Test and Build multiarch
id: docker_build
uses: docker/build-push-action@v2
uses: docker/build-push-action@v3
with:
context: ./
file: ./Dockerfile
outputs: "type=image,push=false"
platforms: linux/amd64,linux/arm64,linux/arm/v7
tags: |
ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/${{ steps.get_repo_name.outputs.repo_name }}:${{ github.sha }}
ghcr.io/${{ env.REPO_OWNER }}/of-watchdog:${{ github.sha }}
41 changes: 16 additions & 25 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,72 +7,63 @@ on:

jobs:
publish:
strategy:
matrix:
go-version: [ 1.18.x ]
os: [ ubuntu-latest ]
runs-on: ${{ matrix.os }}
permissions:
actions: read
checks: write
contents: write
actions: read
issues: read
packages: write
pull-requests: read
repository-projects: read
statuses: read

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@master
with:
fetch-depth: 1
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
go-version: 1.19.x
- name: Make all
run: make all

- name: Get TAG
id: get_tag
run: echo ::set-output name=TAG::${GITHUB_REF#refs/tags/}
run: echo TAG=${GITHUB_REF#refs/tags/} >> $GITHUB_ENV

- name: Get Repo Owner
id: get_repo_owner
run: >
echo ::set-output name=repo_owner::$(echo ${{ github.repository_owner }} |
tr '[:upper:]' '[:lower:]')
- name: Get Repo Name
id: get_repo_name
run: >
echo ::set-output name=repo_name::$(echo ${{ github.repository }} |
tr '[:upper:]' '[:lower:]' |
awk -F'/' '{print $2}')
run: echo "REPO_OWNER=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" > $GITHUB_ENV

- name: Set up QEMU
uses: docker/setup-qemu-action@v1
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v2

- name: Login to Docker Registry
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io

- name: Docker Build and Push
uses: docker/build-push-action@v2
uses: docker/build-push-action@v3
with:
context: ./
file: ./Dockerfile
push: true
platforms: linux/amd64,linux/arm64,linux/arm/v7
tags: |
ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/${{ steps.get_repo_name.outputs.repo_name }}:${{ github.sha }}
ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/${{ steps.get_repo_name.outputs.repo_name }}:${{ steps.get_tag.outputs.TAG }}
ghcr.io/${{ steps.get_repo_owner.outputs.repo_owner }}/${{ steps.get_repo_name.outputs.repo_name }}:latest
ghcr.io/${{ env.REPO_OWNER }}/of-watchdog:${{ github.sha }}
ghcr.io/${{ env.REPO_OWNER }}/of-watchdog:${{ steps.get_tag.outputs.TAG }}
ghcr.io/${{ env.REPO_OWNER }}/of-watchdog:latest
- name: Upload release binaries
uses: alexellis/upload-assets@0.2.2
uses: alexellis/upload-assets@0.4.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ ARG TARGETARCH

COPY --from=cache /fwatchdog-$TARGETARCH ./fwatchdog

ENTRYPOINT ["/fwatchdog"]
ENTRYPOINT ["/fwatchdog"]

0 comments on commit 9ca5a78

Please sign in to comment.