Skip to content

Commit

Permalink
ci(repo): fix and improvements in release actions (#41)
Browse files Browse the repository at this point in the history
* ci(repo): fix and improvements in release actions

* ci: fix docker username on ci action

* ci: add permission field on docker action

* ci: update actions versions

* ci: action run

* ci: fix docker username for publish

* ci: fix docker image publish action
  • Loading branch information
pedronauck committed Jul 8, 2024
1 parent bdbde8d commit 82f54ab
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 58 deletions.
8 changes: 5 additions & 3 deletions .github/actions/docker-publish/action.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Build & Push Docker
description: Build a Dockerfile and publish to the registry

inputs:
compose-version:
Expand Down Expand Up @@ -45,11 +46,12 @@ runs:
using: composite
steps:
- name: Log in to the ghcr.io registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ${{ inputs.registry }}
username: ${{ inputs.username }}
password: ${{ inputs.password }}
logout: false

- name: Docker meta
id: meta
Expand All @@ -63,10 +65,10 @@ runs:
type=semver,pattern={{raw}}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v3

- name: Build and push the image to ghcr.io
uses: docker/build-push-action@v4
uses: docker/build-push-action@v6
id: publish
with:
context: ${{ inputs.context }}
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/docker_publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@ name: Build and publish Docker image

on:
push:
branches:
- main
branches: [main]
pull_request:
types: [opened, synchronize]
release:
types: [published]

permissions:
contents: read
packages: write

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
Expand All @@ -22,13 +25,13 @@ jobs:
(github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name == github.repository)
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Build and push Fuel Core NATS image
uses: ./.github/actions/docker-publish
id: publish
with:
username: ${{ github.repository_owner }}
password: ${{ secrets.REPO_TOKEN }}
password: ${{ secrets.GITHUB_TOKEN }}
image: ghcr.io/fuellabs/fuel-core-nats
dockerfile: docker/fuel-core-nats.Dockerfile
2 changes: 1 addition & 1 deletion .github/workflows/helm_publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:

steps:
- name: Check out code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Package and Push Charts
uses: bsord/helm-push@v4.1.0
Expand Down
52 changes: 3 additions & 49 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
run: ls -R artifacts

- name: Cache Artifacts
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: artifacts
key: ${{ runner.os }}-artifacts-${{ github.sha }}
Expand All @@ -95,10 +95,10 @@ jobs:

steps:
- name: Checkout Repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Restore Artifacts Cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: artifacts
key: ${{ runner.os }}-artifacts-${{ github.sha }}
Expand All @@ -116,49 +116,3 @@ jobs:
with:
publish-delay: 60000
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}

publish-docker-image:
runs-on: buildjet-4vcpu-ubuntu-2204
permissions:
contents: read
actions: write
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: |
ghcr.io/fuellabs/fuel-core-nats
tags: |
type=sha
type=ref,event=branch
type=ref,event=tag
type=semver,pattern={{raw}}
type=raw,value=sha-{{sha}}-{{date 'YYYYMMDDhhmmss'}}
flavor: |
latest=${{ github.ref == 'refs/heads/master' }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to the ghcr.io registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.REPO_TOKEN }}

- name: Build and push the image to ghcr.io
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/arm64
file: docker/fuel-core-nats.Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=ghcr.io/fuellabs/fuel-core-nats-cache:latest
cache-to: type=registry,ref=ghcr.io/fuellabs/fuel-core-nats-cache:latest,mode=max
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
.cov
lcov.info
.env
node_modules/
pnpm-lock.yaml
node_modules/
./package.json
tmp

0 comments on commit 82f54ab

Please sign in to comment.