mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-24 21:34:06 -06:00
Automated commit at Tue Apr 30 18:30:00 CEST 2024
This commit is contained in:
parent
a3dec3527b
commit
02fd66cd9d
@ -1,6 +1,12 @@
|
||||
|
||||
[[Creating tags based on conventional commits with github actions]]
|
||||
|
||||
[[Managing permissions for GitHub Actions to create packages]]
|
||||
|
||||
[[Using matrix - matrices in GitHub Actions for looping jobs]]
|
||||
|
||||
|
||||
|
||||
## Links:
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
Actions
|
||||
- [[Building multiple Docker images using automatic versioning using GitHub Actions]]
|
||||
- [[Building multiple Docker images using automatic versioning using GitHub Actions - index]]
|
||||
|
||||
|
||||
## Links:
|
||||
|
||||
@ -0,0 +1,35 @@
|
||||
- On the main page of your organization, go to Packages
|
||||
- Go to the package and open "Package settings" in the right sidebar
|
||||
- Under Manage Actions access, add the repo as the source
|
||||
- Make sure to allow Write acces
|
||||
|
||||
![[Pasted image 20240429145500.png]]
|
||||
|
||||
In the source repo, where the GitHub Actions Workflow is running, go to settings, actions, select the workflow, and add write permission there too.
|
||||
|
||||
![[Pasted image 20240429151841.png]]
|
||||
|
||||
Finally, we also need to add permissions in the workflow yaml:
|
||||
|
||||
```yaml
|
||||
build_and_push:
|
||||
name: Build image & push
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
```
|
||||
|
||||
See also:
|
||||
|
||||
[github actions - ERROR: denied: installation not allowed to Create organization package - Stack Overflow](https://stackoverflow.com/questions/76607955/error-denied-installation-not-allowed-to-create-organization-package)
|
||||
|
||||
[denied: installation not allowed to Create organization package · Issue #606 · docker/build-push-action (github.com)](https://github.com/docker/build-push-action/issues/606)
|
||||
|
||||
|
||||
|
||||
## Links:
|
||||
|
||||
|
||||
|
||||
202404301753
|
||||
@ -0,0 +1,55 @@
|
||||
One of the problems I needed to solve was that I needed build multiple images, but I didn't want to have a code block for each. After some research I found a way to loop over multiple values in GitHub Actions using matrices.
|
||||
|
||||
In the example below, I set three variables in the matrix and each of these are called in the Build and push step.
|
||||
|
||||
```yaml
|
||||
build_and_push:
|
||||
permissions:
|
||||
contents: write
|
||||
packages: write
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- image: ghcr.io/ssi-dk/sap-web
|
||||
dockerfile: app/Dockerfile
|
||||
path: app
|
||||
- image: ghcr.io/ssi-dk/sap-api
|
||||
dockerfile: web/Dockerfile
|
||||
path: web
|
||||
- image: ghcr.io/ssi-dk/bifrost-queue-broker
|
||||
dockerfile: bifrost/bifrost_queue_broker/Dockerfile
|
||||
path: bifrost/bifrost_queue_broker
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
# loops over all images in the matrix defined on top
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: ${{ matrix.path }}
|
||||
platforms: linux/amd64
|
||||
tags: ${{ matrix.image }}:${{ needs.prepare_tag.outputs.tag }}
|
||||
file: ${{ matrix.dockerfile }}
|
||||
push: true
|
||||
|
||||
```
|
||||
|
||||
|
||||
## Links:
|
||||
|
||||
[Using a matrix for your jobs - GitHub Docs](https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs)
|
||||
|
||||
202404291839
|
||||
Loading…
Reference in New Issue
Block a user