From f47fe6014ba9c4a42ace0a45cd1122147df66e8c Mon Sep 17 00:00:00 2001 From: Kalle Westerling Date: Fri, 12 Jul 2024 09:50:24 +0100 Subject: [PATCH 01/12] Adding in `GITHUB_TOKEN` instead of `GH_TOKEN` --- .github/workflows/build.yml | 2 +- .github/workflows/tests.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b9a859f64..5af7615d5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,7 +26,7 @@ jobs: with: registry: docker.pkg.github.com username: ${{ github.actor }} - password: ${{ secrets.GH_TOKEN }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push Docker image uses: docker/build-push-action@v2 with: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b74fabf63..5e45956d8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -17,7 +17,7 @@ jobs: with: registry: docker.pkg.github.com username: ${{ github.actor }} - password: ${{ secrets.GH_TOKEN }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Pull and run Docker image run: | docker pull docker.pkg.github.com/seshat-global-history-databank/seshat/tests-image:latest From de3f7503132945b88e99e853a1e40445f6329cf8 Mon Sep 17 00:00:00 2001 From: Kalle Westerling Date: Fri, 12 Jul 2024 09:52:00 +0100 Subject: [PATCH 02/12] Adding in branch name for testing --- .github/workflows/build.yml | 4 ++-- .github/workflows/tests.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5af7615d5..a17a0889a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,13 +3,13 @@ name: build_docker_image on: push: - branches: [dev] + branches: [dev, test-github-actions] paths: - 'Dockerfile' - 'requirements.txt' - '.github/workflows/build.yml' pull_request: - branches: [dev] + branches: [dev, test-github-actions] paths: - 'Dockerfile' - 'requirements.txt' diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5e45956d8..1e2bdac3a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -3,9 +3,9 @@ name: test_code on: push: - branches: [dev] + branches: [dev, test-github-actions] pull_request: - branches: [dev] + branches: [dev, test-github-actions] jobs: test_core: From c84496524285957d34231bf26409e10546ec0fc2 Mon Sep 17 00:00:00 2001 From: Kalle Westerling Date: Fri, 12 Jul 2024 09:54:20 +0100 Subject: [PATCH 03/12] Changing hard-coded actor to GitHub actor --- .github/workflows/build.yml | 2 +- .github/workflows/tests.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a17a0889a..18ad4a6bb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -32,4 +32,4 @@ jobs: with: context: . push: true - tags: docker.pkg.github.com/seshat-global-history-databank/seshat/tests-image:latest \ No newline at end of file + tags: docker.pkg.github.com/${{ github.actor }}/seshat/tests-image:latest \ No newline at end of file diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1e2bdac3a..14bd6c51b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -20,7 +20,7 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Pull and run Docker image run: | - docker pull docker.pkg.github.com/seshat-global-history-databank/seshat/tests-image:latest + docker pull docker.pkg.github.com/${{ github.actor }}/seshat/tests-image:latest docker run -d -p 5432:5432 -v ${{ github.workspace }}:/seshat -e DJANGO_SETTINGS_MODULE=seshat.settings.local -e POSTGRES_PASSWORD=postgres -e PGDATA=/var/lib/postgresql/data/db-files/ -e GITHUB_ACTIONS='true' --name seshat_testing docker.pkg.github.com/seshat-global-history-databank/seshat/tests-image:latest - name: Sleep, then check PostgreSQL connectivity run: | From 198e132656c961d303f1d9a2708a39283990b7fc Mon Sep 17 00:00:00 2001 From: Kalle Westerling Date: Fri, 12 Jul 2024 10:02:54 +0100 Subject: [PATCH 04/12] Adding in correct actor --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 14bd6c51b..882a212b4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -21,7 +21,7 @@ jobs: - name: Pull and run Docker image run: | docker pull docker.pkg.github.com/${{ github.actor }}/seshat/tests-image:latest - docker run -d -p 5432:5432 -v ${{ github.workspace }}:/seshat -e DJANGO_SETTINGS_MODULE=seshat.settings.local -e POSTGRES_PASSWORD=postgres -e PGDATA=/var/lib/postgresql/data/db-files/ -e GITHUB_ACTIONS='true' --name seshat_testing docker.pkg.github.com/seshat-global-history-databank/seshat/tests-image:latest + docker run -d -p 5432:5432 -v ${{ github.workspace }}:/seshat -e DJANGO_SETTINGS_MODULE=seshat.settings.local -e POSTGRES_PASSWORD=postgres -e PGDATA=/var/lib/postgresql/data/db-files/ -e GITHUB_ACTIONS='true' --name seshat_testing docker.pkg.github.com/${{ github.actor }}/seshat/tests-image:latest - name: Sleep, then check PostgreSQL connectivity run: | sleep 10 From 553bb74bb1e466b71d53de79dd52f46c48261541 Mon Sep 17 00:00:00 2001 From: Kalle Westerling Date: Fri, 12 Jul 2024 10:02:59 +0100 Subject: [PATCH 05/12] Changing versions --- .github/workflows/build.yml | 6 +++--- .github/workflows/tests.yml | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 18ad4a6bb..118bd9569 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,15 +20,15 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Login to GitHub Packages - uses: docker/login-action@v1 + uses: docker/login-action@v3 with: registry: docker.pkg.github.com username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push Docker image - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v6 with: context: . push: true diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 882a212b4..ac4037733 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -11,9 +11,9 @@ jobs: test_core: runs-on: ['ubuntu-latest'] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Login to GitHub Packages - uses: docker/login-action@v1 + uses: docker/login-action@v3 with: registry: docker.pkg.github.com username: ${{ github.actor }} From 7378893fffb14417cddea20e0bdf6ae4f2e09fcc Mon Sep 17 00:00:00 2001 From: Kalle Westerling Date: Fri, 12 Jul 2024 10:15:22 +0100 Subject: [PATCH 06/12] Cleaning up branch names --- .github/workflows/build.yml | 4 ++-- .github/workflows/tests.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 118bd9569..1788caef6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,13 +3,13 @@ name: build_docker_image on: push: - branches: [dev, test-github-actions] + branches: [dev] paths: - 'Dockerfile' - 'requirements.txt' - '.github/workflows/build.yml' pull_request: - branches: [dev, test-github-actions] + branches: [dev] paths: - 'Dockerfile' - 'requirements.txt' diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ac4037733..591f4b0ec 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -3,9 +3,9 @@ name: test_code on: push: - branches: [dev, test-github-actions] + branches: [dev] pull_request: - branches: [dev, test-github-actions] + branches: [dev] jobs: test_core: From 888315c9e97f9eb3979189894158cec547cbab7c Mon Sep 17 00:00:00 2001 From: Kalle Westerling Date: Fri, 12 Jul 2024 10:41:47 +0100 Subject: [PATCH 07/12] Change from `actor` to `repository` --- .github/workflows/build.yml | 2 +- .github/workflows/tests.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1788caef6..a8a51cab3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -32,4 +32,4 @@ jobs: with: context: . push: true - tags: docker.pkg.github.com/${{ github.actor }}/seshat/tests-image:latest \ No newline at end of file + tags: docker.pkg.github.com/${{ github.repository }}/seshat/tests-image:latest \ No newline at end of file diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 591f4b0ec..40ac86c82 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -20,8 +20,8 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Pull and run Docker image run: | - docker pull docker.pkg.github.com/${{ github.actor }}/seshat/tests-image:latest - docker run -d -p 5432:5432 -v ${{ github.workspace }}:/seshat -e DJANGO_SETTINGS_MODULE=seshat.settings.local -e POSTGRES_PASSWORD=postgres -e PGDATA=/var/lib/postgresql/data/db-files/ -e GITHUB_ACTIONS='true' --name seshat_testing docker.pkg.github.com/${{ github.actor }}/seshat/tests-image:latest + docker pull docker.pkg.github.com/${{ github.repository }}/seshat/tests-image:latest + docker run -d -p 5432:5432 -v ${{ github.workspace }}:/seshat -e DJANGO_SETTINGS_MODULE=seshat.settings.local -e POSTGRES_PASSWORD=postgres -e PGDATA=/var/lib/postgresql/data/db-files/ -e GITHUB_ACTIONS='true' --name seshat_testing docker.pkg.github.com/${{ github.repository }}/seshat/tests-image:latest - name: Sleep, then check PostgreSQL connectivity run: | sleep 10 From ce8ac3198d8ed1e410942a0885a16f47d9bb1fe6 Mon Sep 17 00:00:00 2001 From: Kalle Westerling Date: Fri, 12 Jul 2024 10:57:14 +0100 Subject: [PATCH 08/12] Enforcing lowercase See https://github.com/orgs/community/discussions/25768 --- .github/workflows/build.yml | 5 ++++- .github/workflows/tests.yml | 7 +++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a8a51cab3..74025b0dc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -27,9 +27,12 @@ jobs: registry: docker.pkg.github.com username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + - name: downcase REPO + run: | + echo "REPO=${GITHUB_REPOSITORY@L}" >> ${GITHUB_ENV} - name: Build and push Docker image uses: docker/build-push-action@v6 with: context: . push: true - tags: docker.pkg.github.com/${{ github.repository }}/seshat/tests-image:latest \ No newline at end of file + tags: docker.pkg.github.com/${ env.REPO }/seshat/tests-image:latest \ No newline at end of file diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 40ac86c82..896cc61a0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -18,10 +18,13 @@ jobs: registry: docker.pkg.github.com username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + - name: downcase REPO + run: | + echo "REPO=${GITHUB_REPOSITORY@L}" >> ${GITHUB_ENV} - name: Pull and run Docker image run: | - docker pull docker.pkg.github.com/${{ github.repository }}/seshat/tests-image:latest - docker run -d -p 5432:5432 -v ${{ github.workspace }}:/seshat -e DJANGO_SETTINGS_MODULE=seshat.settings.local -e POSTGRES_PASSWORD=postgres -e PGDATA=/var/lib/postgresql/data/db-files/ -e GITHUB_ACTIONS='true' --name seshat_testing docker.pkg.github.com/${{ github.repository }}/seshat/tests-image:latest + docker pull docker.pkg.github.com/${ env.REPO }/seshat/tests-image:latest + docker run -d -p 5432:5432 -v ${{ github.workspace }}:/seshat -e DJANGO_SETTINGS_MODULE=seshat.settings.local -e POSTGRES_PASSWORD=postgres -e PGDATA=/var/lib/postgresql/data/db-files/ -e GITHUB_ACTIONS='true' --name seshat_testing docker.pkg.github.com/${ env.REPO }/seshat/tests-image:latest - name: Sleep, then check PostgreSQL connectivity run: | sleep 10 From 779af59ae02183d97c11d716a0e82224eacaf760 Mon Sep 17 00:00:00 2001 From: Kalle Westerling Date: Fri, 12 Jul 2024 10:58:37 +0100 Subject: [PATCH 09/12] Temp branch names in again --- .github/workflows/build.yml | 4 ++-- .github/workflows/tests.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 74025b0dc..69fabe03c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,13 +3,13 @@ name: build_docker_image on: push: - branches: [dev] + branches: [dev, test-github-actions] paths: - 'Dockerfile' - 'requirements.txt' - '.github/workflows/build.yml' pull_request: - branches: [dev] + branches: [dev, test-github-actions] paths: - 'Dockerfile' - 'requirements.txt' diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 896cc61a0..b81cb70ec 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -3,9 +3,9 @@ name: test_code on: push: - branches: [dev] + branches: [dev, test-github-actions] pull_request: - branches: [dev] + branches: [dev, test-github-actions] jobs: test_core: From b4fc176d8cea744694aaeb0889016a152f3d200c Mon Sep 17 00:00:00 2001 From: Kalle Westerling Date: Fri, 12 Jul 2024 11:02:06 +0100 Subject: [PATCH 10/12] Test setting environment variables instead See https://github.com/orgs/community/discussions/27086 --- .github/workflows/build.yml | 8 +++++--- .github/workflows/tests.yml | 10 ++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 69fabe03c..3fd7f045c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -27,12 +27,14 @@ jobs: registry: docker.pkg.github.com username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: downcase REPO + - name: set lower case owner name run: | - echo "REPO=${GITHUB_REPOSITORY@L}" >> ${GITHUB_ENV} + echo "OWNER_LC=${OWNER,,}" >>${GITHUB_ENV} + env: + OWNER: '${{ github.repository_owner }}' - name: Build and push Docker image uses: docker/build-push-action@v6 with: context: . push: true - tags: docker.pkg.github.com/${ env.REPO }/seshat/tests-image:latest \ No newline at end of file + tags: docker.pkg.github.com/${{ env.OWNER_LC }}/seshat/tests-image:latest \ No newline at end of file diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b81cb70ec..157edef65 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -18,13 +18,15 @@ jobs: registry: docker.pkg.github.com username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: downcase REPO + - name: set lower case owner name run: | - echo "REPO=${GITHUB_REPOSITORY@L}" >> ${GITHUB_ENV} + echo "OWNER_LC=${OWNER,,}" >>${GITHUB_ENV} + env: + OWNER: '${{ github.repository_owner }}' - name: Pull and run Docker image run: | - docker pull docker.pkg.github.com/${ env.REPO }/seshat/tests-image:latest - docker run -d -p 5432:5432 -v ${{ github.workspace }}:/seshat -e DJANGO_SETTINGS_MODULE=seshat.settings.local -e POSTGRES_PASSWORD=postgres -e PGDATA=/var/lib/postgresql/data/db-files/ -e GITHUB_ACTIONS='true' --name seshat_testing docker.pkg.github.com/${ env.REPO }/seshat/tests-image:latest + docker pull docker.pkg.github.com/${{ env.OWNER_LC }}/seshat/tests-image:latest + docker run -d -p 5432:5432 -v ${{ github.workspace }}:/seshat -e DJANGO_SETTINGS_MODULE=seshat.settings.local -e POSTGRES_PASSWORD=postgres -e PGDATA=/var/lib/postgresql/data/db-files/ -e GITHUB_ACTIONS='true' --name seshat_testing docker.pkg.github.com/${{ env.OWNER_LC }}/seshat/tests-image:latest - name: Sleep, then check PostgreSQL connectivity run: | sleep 10 From 587f5587bda218da89c0749b9311cff183d1df00 Mon Sep 17 00:00:00 2001 From: Kalle Westerling Date: Fri, 12 Jul 2024 11:06:25 +0100 Subject: [PATCH 11/12] Adding permissions See https://stackoverflow.com/questions/75926611/github-workflow-to-push-docker-image-to-ghcr-io --- .github/workflows/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3fd7f045c..451628dcb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,6 +18,8 @@ on: jobs: build: runs-on: ubuntu-latest + permissions: + packages: write steps: - name: Checkout code uses: actions/checkout@v4 From 7135eba63f3c06da47f2e3b647fe1d8bdf400164 Mon Sep 17 00:00:00 2001 From: Kalle Westerling Date: Fri, 12 Jul 2024 11:23:52 +0100 Subject: [PATCH 12/12] Upgrading permissions --- .github/workflows/build.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 451628dcb..226d9807c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,8 +18,7 @@ on: jobs: build: runs-on: ubuntu-latest - permissions: - packages: write + permissions: write-all steps: - name: Checkout code uses: actions/checkout@v4